Send Beginners mailing list submissions to
[email protected]
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
[email protected]
You can reach the person managing the list at
[email protected]
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."
Today's Topics:
1. Re: Context reducion Stack overflow (Marco T?lio Gontijo e Silva)
2. Re: Re: Programa??o Funcional - TP1
(Marco T?lio Gontijo e Silva)
3. parallel program in haskell in 5 steps (Jack Kennedy)
4. Re: parallel program in haskell in 5 steps (Michael Snoyman)
5. Re: parallel program in haskell in 5 steps (Ertugrul Soeylemez)
6. Re: parallel program in haskell in 5 steps (Jack Kennedy)
----------------------------------------------------------------------
Message: 1
Date: Tue, 05 May 2009 15:07:16 -0300
From: Marco T?lio Gontijo e Silva <[email protected]>
Subject: Re: [Haskell-beginners] Context reducion Stack overflow
To: [email protected]
Message-ID: <1241546836.5122.522.ca...@zezinho>
Content-Type: text/plain; charset="UTF-8"
Em Ter, 2009-05-05 Ã s 11:33 -0400, Brent Yorgey escreveu:
> On Tue, May 05, 2009 at 10:28:10AM -0300, Marco Túlio Gontijo e Silva wrote:
> > Em Seg, 2009-05-04 Ã s 15:54 -0400, Brent Yorgey escreveu:
> > > On Mon, May 04, 2009 at 11:59:54AM -0300, Marco Túlio Gontijo e Silva
> > > wrote:
> > >
> > > > > instance (F f, M m (f a)) => M m a where
> > > > > mm f v = mm (m f) v
> > >
> > > Perhaps you mean
> > >
> > > instance (F f, M m a) => M m (f a) where ...
> > >
> > > ?
> >
> > No, I really meant what I wrote. An example: If I the instances I
> > wrote:
> >
> > > instance F [] where
> > > m = map
> >
> > > instance M (IORef a) a where
> > > mm = flip modifyIORef
> >
> > I want to define:
> >
> > > instance M (IORef [a]) a where
> > > mm f v = mm (m f) v
> >
> > This could of course be written as:
> >
> > mm = mm . m
> >
> > I'd like to get this last instance automaticly from that definition,
> > having:
> >
> > f = []
> > m = IORef [a]
>
> I don't follow. In order to get
>
> instance M (IORef [a]) a
>
> from
>
> instance (F f, M m (f a)) => M m a
>
> would require
>
> instance M (IORef [a]) (f a)
>
> for some f, which you don't have.
Yes, I have this instance defined for f = []:
instance M (IORef [a]) [a]
which is a instance of:
instance M (IORef a) a
> I might try rewriting M as
>
> class M f a where
> mm :: (a -> a) -> f a -> IO ()
>
> and then your automatic lifting instance would be something like
>
> instance (F f, M f2 a) => M (f :.: f2) a
>
> where :.: denotes functor composition.
Ok, I think this is another possibility. But how could I define :.:?
Greetings.
--
marcot
http://marcot.iaaeee.org/
------------------------------
Message: 2
Date: Tue, 05 May 2009 15:08:01 -0300
From: Marco T?lio Gontijo e Silva <[email protected]>
Subject: Re: [Haskell-beginners] Re: Programa??o Funcional - TP1
To: [email protected]
Message-ID: <1241546881.5122.525.ca...@zezinho>
Content-Type: text/plain
Sorry about this e-mail, I send it by mistake.
Greetings.
--
marcot
http://marcot.iaaeee.org/
------------------------------
Message: 3
Date: Tue, 5 May 2009 12:19:55 -0700
From: Jack Kennedy <[email protected]>
Subject: [Haskell-beginners] parallel program in haskell in 5 steps
To: [email protected]
Message-ID:
<[email protected]>
Content-Type: text/plain; charset="utf-8"
In step 4 of Haskell in 5 Steps [
http://haskell.org/haskellwiki/Haskell_in_5_steps],
a parallel program is given. I changed it very slightly so it would run a
long time (see below).
It compiles and runs but my CPU meter is barely above 50%. I have a dual
core processor.
What in the world would keep this program from completely saturating the
CPU?
import Control.Parallel
main = a `par` b `pseq` print (a + b)
where
a = ack 4 10
b = ack 4 10
fac 0 = 1
fac n = n * fac (n-1)
ack 0 n = n+1
ack m 0 = ack (m-1) 1
ack m n = ack (m-1) (ack m (n-1))
fib 0 = 0
fib 1 = 1
fib n = fib (n-1) + fib (n-2)
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://www.haskell.org/pipermail/beginners/attachments/20090505/2d831639/attachment-0001.htm
------------------------------
Message: 4
Date: Tue, 5 May 2009 22:51:59 +0300
From: Michael Snoyman <[email protected]>
Subject: Re: [Haskell-beginners] parallel program in haskell in 5
steps
To: Jack Kennedy <[email protected]>
Cc: [email protected]
Message-ID:
<[email protected]>
Content-Type: text/plain; charset="utf-8"
How are you running the program? You have to explicitly tell the
compiler/interpreter to use multiple system threads.
Michael
On Tue, May 5, 2009 at 10:19 PM, Jack Kennedy <[email protected]> wrote:
> In step 4 of Haskell in 5 Steps [
> http://haskell.org/haskellwiki/Haskell_in_5_steps],
> a parallel program is given. I changed it very slightly so it would run a
> long time (see below).
>
> It compiles and runs but my CPU meter is barely above 50%. I have a dual
> core processor.
> What in the world would keep this program from completely saturating the
> CPU?
>
> import Control.Parallel
>
> main = a `par` b `pseq` print (a + b)
> where
> a = ack 4 10
> b = ack 4 10
>
> fac 0 = 1
> fac n = n * fac (n-1)
>
> ack 0 n = n+1
> ack m 0 = ack (m-1) 1
> ack m n = ack (m-1) (ack m (n-1))
>
> fib 0 = 0
> fib 1 = 1
> fib n = fib (n-1) + fib (n-2)
>
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://www.haskell.org/pipermail/beginners/attachments/20090505/f77d0f9e/attachment-0001.htm
------------------------------
Message: 5
Date: Tue, 5 May 2009 22:59:23 +0200
From: Ertugrul Soeylemez <[email protected]>
Subject: [Haskell-beginners] Re: parallel program in haskell in 5
steps
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=US-ASCII
Hello Jack,
according to the source code your program should not run for a long
time. If you're using GHC, use the '-threaded' flag when compiling and
also pass the parameters '+RTS -N2' to your program to let it run with
two parallel threads.
However, my experience is that the pure parallel constructs are
currently not really suitable for real world programs. With my dual
core processor I get the expected ~190% CPU time using explicit
parallelism using concurrency (i.e. forkIO and MVars), whereas with pure
constructs like the ones from Control.Parallel and
Control.Parallel.Strategies I get only about 140%.
Greets,
Ertugrul.
Jack Kennedy <[email protected]> wrote:
> In step 4 of Haskell in 5 Steps [
> http://haskell.org/haskellwiki/Haskell_in_5_steps],
> a parallel program is given. I changed it very slightly so it would run a
> long time (see below).
>
> It compiles and runs but my CPU meter is barely above 50%. I have a dual
> core processor.
> What in the world would keep this program from completely saturating the
> CPU?
>
> import Control.Parallel
>
> main = a `par` b `pseq` print (a + b)
> where
> a = ack 4 10
> b = ack 4 10
>
> fac 0 = 1
> fac n = n * fac (n-1)
>
> ack 0 n = n+1
> ack m 0 = ack (m-1) 1
> ack m n = ack (m-1) (ack m (n-1))
>
> fib 0 = 0
> fib 1 = 1
> fib n = fib (n-1) + fib (n-2)
>
--
nightmare = unsafePerformIO (getWrongWife >>= sex)
http://blog.ertes.de/
------------------------------
Message: 6
Date: Tue, 5 May 2009 14:05:56 -0700
From: Jack Kennedy <[email protected]>
Subject: Re: [Haskell-beginners] parallel program in haskell in 5
steps
To: Michael Snoyman <[email protected]>
Cc: [email protected]
Message-ID:
<[email protected]>
Content-Type: text/plain; charset="utf-8"
I am compiling (Windows by the way) using the line from the tutorial:
ghc -O2 --make par.hs -threaded
and running with the line
par +RTS -N2
CPU usage for the process flits around a little, but stays in the 45% - 55%
range.
On Tue, May 5, 2009 at 12:51 PM, Michael Snoyman <[email protected]>wrote:
> How are you running the program? You have to explicitly tell the
> compiler/interpreter to use multiple system threads.
>
> Michael
>
> On Tue, May 5, 2009 at 10:19 PM, Jack Kennedy <[email protected]> wrote:
>
>> In step 4 of Haskell in 5 Steps [
>> http://haskell.org/haskellwiki/Haskell_in_5_steps],
>> a parallel program is given. I changed it very slightly so it would run a
>> long time (see below).
>>
>> It compiles and runs but my CPU meter is barely above 50%. I have a dual
>> core processor.
>> What in the world would keep this program from completely saturating the
>> CPU?
>>
>> import Control.Parallel
>>
>> main = a `par` b `pseq` print (a + b)
>> where
>> a = ack 4 10
>> b = ack 4 10
>>
>> fac 0 = 1
>> fac n = n * fac (n-1)
>>
>> ack 0 n = n+1
>> ack m 0 = ack (m-1) 1
>> ack m n = ack (m-1) (ack m (n-1))
>>
>> fib 0 = 0
>> fib 1 = 1
>> fib n = fib (n-1) + fib (n-2)
>>
>>
>> _______________________________________________
>> Beginners mailing list
>> [email protected]
>> http://www.haskell.org/mailman/listinfo/beginners
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://www.haskell.org/pipermail/beginners/attachments/20090505/ce07c344/attachment.htm
------------------------------
_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
End of Beginners Digest, Vol 11, Issue 5
****************************************