Send Beginners mailing list submissions to
        beginners@haskell.org

To subscribe or unsubscribe via the World Wide Web, visit
        http://www.haskell.org/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:  Pattern matching over functions (Ken KAWAMOTO)
   2.  Parallel Matrix Multiplication (mukesh tiwari)
   3.  Averaging a string of numbers (goodman....@gmail.com)
   4.  Installing regex-pcre (revisited) (MJ Williams)
   5. Re:  Installing regex-pcre (revisited) (Asokan Pichai)
   6. Re:  Installing regex-pcre (revisited) (Stephen Tetley)
   7. Re:  Installing regex-pcre (revisited) (Asokan Pichai)


----------------------------------------------------------------------

Message: 1
Date: Sun, 11 Dec 2011 01:17:57 +0900
From: Ken KAWAMOTO <kentaro.kawam...@gmail.com>
Subject: Re: [Haskell-beginners] Pattern matching over functions
To: Brent Yorgey <byor...@seas.upenn.edu>, beginners@haskell.org
Message-ID:
        <cagbyekoywaxbxrdotqkb+z8syugv90cbujedormkktyrdjn...@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

On Thu, Dec 8, 2011 at 3:14 PM, Brent Yorgey <byor...@seas.upenn.edu> wrote:
> On Wed, Dec 07, 2011 at 06:10:01PM +0100, Giacomo Tesio wrote:
>> I would find already very useful a compiler that is able to understand id f
>> = f, that (\x -> 3 + x) == (\y = 3 + y) == (+3) even if it isn't able to
>> see that (+3) == (\x -> 2 + 1 + x).
>
> But then we would lose referential transparency.

As I understand, this would be against lazy evaluation since it would
request to evaluate expressions in lambda, but I don't see how this
relates to referential transparency.
Can you elaborate this a little bit?

Thanks,
Ken



------------------------------

Message: 2
Date: Sun, 11 Dec 2011 00:39:07 +0530
From: mukesh tiwari <mukeshtiwari.ii...@gmail.com>
Subject: [Haskell-beginners] Parallel Matrix Multiplication
To: beginners@haskell.org
Message-ID:
        <cafhzve8sh-z+gd1f40bjfz2s6xvrpbcsua0dhdcmdx5s4h5...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"

Hello all
I am trying to learn parallel Haskell and  I have gone through couple of
resources ( Real world Haskell and
http://research.microsoft.com/en-us/um/people/simonpj/papers/parallel/AFP08-notes.pdf
).
I understood par and pseq and I wrote matrix multiplication using these two
function but it does not look.  Although I did not get all these details
from ( ./Matpar +RTS -N2 -s ) but none of the sparks converted which is
really important for parallel programming. Could some one please tell me
how to improve this. Also kindly recommend me some  literature for parallel
programming in Haskell.

Regards
Mukesh Tiwari

import Data.List
import Control.Parallel

parHelp :: ( Num a ) => [ a ] -> [ a ] -> a
parHelp [] [] = 0
parHelp ( x : xs ) ( y : ys ) = ret where
        ret = par a ( pseq a ( a + parHelp xs ys ) ) where
            a = x * y


helpMult :: ( Num a ) => [ a ] -> [ [ a ] ] -> [ a ]
helpMult _ [] = []
helpMult x ( y : ys ) = ret where
     ret =  par a ( pseq a  ( a : helpMult x ys ) ) where
       a = parHelp x y


mult :: ( Num a ) => [ [ a ] ] -> [ [ a ] ] -> [ [ a ] ]
mult [] _ = []
mult ( x : xs ) ys = ret where
     ret = par a ( pseq a  ( a : mult xs ys ) ) where
        a = helpMult x ys

main = print $ mult [[1 .. 4 ] , [ 1 .. 4 ] , [ 1 .. 4 ] , [ 1 .. 4] ] (
transpose [[1 .. 4 ] , [ 1 .. 4 ] , [ 1 .. 4 ] , [ 1 .. 4] ])

[user@haskell Programming]$ ghc -O2 -threaded -rtsopts Matpar.hs
[1 of 1] Compiling Main             ( Matpar.hs, Matpar.o )
Linking Matpar ...
[user@haskell Programming]$ ./Matpar +RTS -N2 -s
./Matpar +RTS -N2 -s
[[10,20,30,40],[10,20,30,40],[10,20,30,40],[10,20,30,40]]
          85,480 bytes allocated in the heap
           5,216 bytes copied during GC
          47,328 bytes maximum residency (1 sample(s))
          22,304 bytes maximum slop
               2 MB total memory in use (0 MB lost due to fragmentation)

  Generation 0:     0 collections,     0 parallel,  0.00s,  0.00s elapsed
  Generation 1:     1 collections,     0 parallel,  0.00s,  0.00s elapsed

  Parallel GC work balance: -nan (0 / 0, ideal 2)

                        MUT time (elapsed)       GC time  (elapsed)
  Task  0 (worker) :    0.00s    (  0.00s)       0.00s    (  0.00s)
  Task  1 (worker) :    0.00s    (  0.00s)       0.00s    (  0.00s)
  Task  2 (bound)  :    0.00s    (  0.00s)       0.00s    (  0.00s)
  Task  3 (worker) :    0.00s    (  0.00s)       0.00s    (  0.00s)

*  SPARKS: 84 (0 converted, 0 pruned)*

  INIT  time    0.00s  (  0.00s elapsed)
  MUT   time    0.00s  (  0.00s elapsed)
  GC    time    0.00s  (  0.00s elapsed)
  EXIT  time    0.00s  (  0.00s elapsed)
  Total time    0.00s  (  0.00s elapsed)

  %GC time      33.3%  (13.5% elapsed)

  Alloc rate    42,761,380 bytes per MUT second

  Productivity  33.3% of total user, 45.0% of total elapsed

gc_alloc_block_sync: 0
whitehole_spin: 0
gen[0].sync_large_objects: 0
gen[1].sync_large_objects: 0
[user@haskell Programming]$
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20111211/3c1ab807/attachment-0001.htm>

------------------------------

Message: 3
Date: Sat, 10 Dec 2011 19:21:58 -0800
From: "goodman....@gmail.com" <goodman....@gmail.com>
Subject: [Haskell-beginners] Averaging a string of numbers
To: beginners@haskell.org
Message-ID:
        <cagxbfaoafj49ytl0uhbo2o-x_omr5kbupph-+bfoe7czb+j...@mail.gmail.com>
Content-Type: text/plain; charset=UTF-8

Hi beginners list,

I want to take a string of numbers and return the average. It is a
string because I expect the input to be from STDIN or a file. I would
like it to handle infinite lists. Further, I create the Stats data
structure because later I will add support for other statistics, like
max, min, sum, prod, etc. The following code works, but I'm not sure
it's the proper way to do things in Haskell. For instance, maybe I
could use a fold method instead of the explicit recursion in getStats?
Could you please let me know if anything looks clunky or could be
improved (efficiency, aesthetics, etc)? Thank you

-- avg.hs
-- sm is sum, len is number of elements
data Stats = Stats { sm :: Double, len :: Int } deriving Show

getAverage :: String -> Double
getAverage str = (sm s / fromIntegral (len s))
                where s = (getStats . readNumbers . lines) str


getStats :: [Double] -> Stats
getStats []     = Stats 0.0 0
getStats [x]    = Stats x 1
getStats (x:xs) = Stats (x + (sm s)) ((len s) + 1)
                 where s = getStats xs

readNumbers :: [String] -> [Double]
readNumbers = map read
-- end avg.hs

And here's the results in ghci:

*Main> :load avg.hs
[1 of 1] Compiling Main             ( avg.hs, interpreted )
Ok, modules loaded: Main.
*Main> getAverage "0"
0.0
*Main> getAverage "1.4\n0.5\n85.2\n30.2\n-10"
21.46
*Main> getAverage ""
NaN

-- 
-Michael Wayne Goodman



------------------------------

Message: 4
Date: Sun, 11 Dec 2011 04:38:05 +0000
From: MJ Williams <matthewjwilliams...@gmail.com>
Subject: [Haskell-beginners] Installing regex-pcre (revisited)
To: beginners@haskell.org
Message-ID: <4ee433ad.cdc6e30a.1271.ffffc...@mx.google.com>
Content-Type: text/plain; charset="us-ascii"; format=flowed

Hi guys,
I understand there's a UNIX-like environment that one can install on 
Windows and it may already include clibpcre that GHC requires for 
installing regex-pcre. for the life of me I can't remember its name. 
Does anyone know what I'm referring to?
Regards
Matthew




------------------------------

Message: 5
Date: Sun, 11 Dec 2011 10:26:08 +0530
From: Asokan Pichai <paso...@talentsprint.com>
Subject: Re: [Haskell-beginners] Installing regex-pcre (revisited)
To: MJ Williams <matthewjwilliams...@gmail.com>
Cc: beginners@haskell.org
Message-ID:
        <CAJAvg=HA6DJuSPJBbJ6ZRY+fz7qntf+wQyMwTnN+NUU4f=4...@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

On Sun, Dec 11, 2011 at 10:08 AM, MJ Williams
<matthewjwilliams...@gmail.com> wrote:
> Hi guys,
> I understand there's a UNIX-like environment that one can install on Windows
CYGWIN?

> and it may already include clibpcre that GHC requires for installing
> regex-pcre. for the life of me I can't remember its name. Does anyone know
> what I'm referring to?
> Regards
> Matthew

Asokan



------------------------------

Message: 6
Date: Sun, 11 Dec 2011 07:13:58 +0000
From: Stephen Tetley <stephen.tet...@gmail.com>
Subject: Re: [Haskell-beginners] Installing regex-pcre (revisited)
Cc: beginners@haskell.org
Message-ID:
        <cab2tprbge-xcc31ehuoz0hlexmqn8cdcxyamvltff6jwg2u...@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

On 11 December 2011 04:56, Asokan Pichai <paso...@talentsprint.com> wrote:
> On Sun, Dec 11, 2011 at 10:08 AM, MJ Williams
> <matthewjwilliams...@gmail.com> wrote:
>> Hi guys,
>> I understand there's a UNIX-like environment that one can install on Windows
> CYGWIN?
>

No - for binding to C libraries you want to use MinGW / MSYS.

The reason for this is basically that everyone else does. Linking
static libraries is a bit different internally to Cygwin and it does
not seem to "just work" whereas it usually does on MinGW provided you
have the C library already working.



------------------------------

Message: 7
Date: Sun, 11 Dec 2011 14:11:25 +0530
From: Asokan Pichai <paso...@talentsprint.com>
Subject: Re: [Haskell-beginners] Installing regex-pcre (revisited)
To: Stephen Tetley <stephen.tet...@gmail.com>
Cc: beginners@haskell.org
Message-ID:
        <CAJAvg=HLgHC83i27oRG2jo1YG0kXgXMGGG8jaW=dgcovdkn...@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

On Sun, Dec 11, 2011 at 12:43 PM, Stephen Tetley
<stephen.tet...@gmail.com> wrote:
> On 11 December 2011 04:56, Asokan Pichai <paso...@talentsprint.com> wrote:
>> On Sun, Dec 11, 2011 at 10:08 AM, MJ Williams
>> <matthewjwilliams...@gmail.com> wrote:
>>> Hi guys,
>>> I understand there's a UNIX-like environment that one can install on Windows
>> CYGWIN?
>>
>
> No - for binding to C libraries you want to use MinGW / MSYS.
AFAIK MingW is intended to develop WIn32 apps on a Linux platform.

The OP's question is for a Unix-like environment on Windows; which
is Cygwin.

>
> The reason for this is basically that everyone else does. Linking
> static libraries is a bit different internally to Cygwin and it does
> not seem to "just work" whereas it usually does on MinGW provided you
> have the C library already working.

I do not understand this part.

Asokan



------------------------------

_______________________________________________
Beginners mailing list
Beginners@haskell.org
http://www.haskell.org/mailman/listinfo/beginners


End of Beginners Digest, Vol 42, Issue 12
*****************************************

Reply via email to