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:  Haskell, Ray Tracing, Parallel Computation (Tom Davie)
   2.  MVar blocked or not? (Adrian Adshead)
   3. Re:  Haskell, Ray Tracing, Parallel Computation (Jon Harrop)
   4. Re:  Haskell, Ray Tracing, Parallel Computation (Antoine Latter)
   5.  Re: Haskell, Ray Tracing, Parallel Computation (Christian Maeder)
   6.  using "read" (Luca Ciciriello)
   7. Re:  using "read" (Iustin Pop)


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

Message: 1
Date: Fri, 15 Jan 2010 15:17:38 +0000
From: Tom Davie <[email protected]>
Subject: Re: [Haskell-beginners] Haskell, Ray Tracing, Parallel
        Computation
To: Jon Harrop <[email protected]>
Cc: [email protected]
Message-ID:
        <[email protected]>
Content-Type: text/plain; charset="windows-1252"

You should be able to get it just by running cabal update & cabal install
AC-Vector.

With 6.12 it may be that you don't have the cabal-install package installed
already, so cabal install won't work.

If that's the case, you'll need to download cabal-install and it's deps and
install it using runhaskell Setup.hs configure, runhaskell Setup.hs build ad
runhaskell Setup.hs install.

That, or wait until 6.12 is considered stable enough to become part of the
Haskell platform.

For reference – I can quite believe that Haskell came out incredibly fast
here – it's trivially easy to parallelise haskell programs, and GHC deals
with parallelisation well (except for garbage collection unfortunately).

Bob

On Fri, Jan 15, 2010 at 4:25 PM, Jon Harrop <[email protected]> wrote:

>
> Someone has tried to parallelize Lennart's Haskell from my ray tracer
> language
> comparison and they are claiming awesome performance results for Haskell,
> even beating HLVM:
>
>  http://poorlytyped.blogspot.com/2010/01/haskell-ray-tracing-parallel.html
>
> Frankly, I don't believe their claims for a second. So I'd like to test
> their
> code for myself. However, apparently their code needs some third-party
> library that can be installed with:
>
>  cabal install AC-Vector
>
> but, on my machine, that only seems to make the library accessible to GHC
> 6.10
> and not to GHC 6.12 (which is needed to compile this benchmark).
>
> What is the easiest way for me to get this library working under GHC 6.12?
>
> --
> Dr Jon Harrop, Flying Frog Consultancy Ltd.
> http://www.ffconsultancy.com/?e
> _______________________________________________
> 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/20100115/f3ed063b/attachment-0001.html

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

Message: 2
Date: Fri, 15 Jan 2010 16:08:43 +0000 (GMT)
From: Adrian Adshead <[email protected]>
Subject: [Haskell-beginners] MVar blocked or not?
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset="iso-8859-1"

Hi everyone,

I have a beginer question on using MVar.

In the simple case I am getting what I expect...


***CODE***
module Main ( main ) where

import Control.Concurrent
import System.IO

main = do
  mv <- newEmptyMVar
  putMVar mv 'a'
  threadDelay (5 * 10^6)
  putMVar mv 'b'
  threadDelay (5 * 10^6)
***/CODE***


Output after the first 5 second delay is :-

Demo.exe: thread blocked indefinitely



It even works as expected when there is a reading thread

***CODE***
module Main ( main ) where

import Control.Concurrent
import Control.Monad
import System.IO

main = do
  mv <- newEmptyMVar
  forkIO (readMV mv)
  putMVar mv 'a'
  threadDelay (5 * 10^6)
  putMVar mv 'b'
  threadDelay (5 * 10^6)

readMV mv = forever $ do
  ch <- takeMVar mv
  putChar ch >> hFlush stdout
***/CODE***

Output including expected delays :-
ab



Then it starts to act unexpectedly

***CODE***
module Main ( main ) where

import Control.Concurrent
import Control.Monad
import System.IO

main = do
  mv <- newEmptyMVar
  forkIO (readMV mv)
  putMVar mv 'a'
  threadDelay (5 * 10^6)
  putMVar mv 'b'
  threadDelay (5 * 10^6)

readMV mv = forever $ do
  ch <- modifyMVar mv modMV
  putChar ch >> hFlush stdout
  threadDelay (9*10^5)

modMV 'a' = return ('c','a')
modMV 'c' = return ('a','c')
modMV x = return (x,x)
***/CODE***

Output is :-
acacac


The problem is that the output stops after 5 seconds
and the program exits after 10 seconds. But why?

Questions:-

1. Why does the output stop? (Shouldn't the reader thread
continue even if the main thread blocks on the second putMVar?)

2. Why does it exit? (Shouldn't it be blocked at the second
putMVar? The readMV thread now only modifies the MVar so it
should never be empty)

3. Is there a race condition using modifyMVar while there
is another thread blocked in a putMVar? (I am assuming the
second putMVar succeeded, but where did the 'b' go?)

Many thanks for any help

Adrian.


      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
http://www.haskell.org/pipermail/beginners/attachments/20100115/47fb5b2d/attachment-0001.html

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

Message: 3
Date: Fri, 15 Jan 2010 17:24:11 +0000
From: Jon Harrop <[email protected]>
Subject: Re: [Haskell-beginners] Haskell, Ray Tracing, Parallel
        Computation
To: Tom Davie <[email protected]>
Cc: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain;  charset="utf-8"

On Friday 15 January 2010 15:17:38 Tom Davie wrote:
> You should be able to get it just by running cabal update & cabal install
> AC-Vector.

When I run "cabal install" it says:

$ cabal update
Downloading the latest package list from hackage.haskell.org
Note: there is a new version of cabal-install available.
To upgrade, run: cabal install cabal-install

If I run "cabal install cabal-install" as it suggests then it appears to do a 
lot of work, ending with this:

...
[33 of 34] Compiling Distribution.Client.List ( Distribution/Client/List.hs, 
dist/build/cabal/cabal-tmp/Distribution/Client/List.o )
[34 of 34] Compiling Main             ( Main.hs, 
dist/build/cabal/cabal-tmp/Main.o )
Linking dist/build/cabal/cabal ...
Installing executable(s) in /home/jdh30/.cabal/bin

But when I run "cabal install" again it fails to detect the updated 
cabal-install correctly:

$ cabal update
Downloading the latest package list from hackage.haskell.org
Note: there is a new version of cabal-install available.
To upgrade, run: cabal install cabal-install

> With 6.12 it may be that you don't have the cabal-install package installed
> already, so cabal install won't work.
>
> If that's the case, you'll need to download cabal-install and it's deps and
> install it using runhaskell Setup.hs configure, runhaskell Setup.hs build
> ad runhaskell Setup.hs install.

Those "runhaskell" commands don't do anything here. If I use bootstrap.sh then 
I get:

$ ./bootstrap.sh

Error during cabal-install bootstrap:
Version mismatch between ghc and ghc-pkg If you set the GHC variable then set 
GHC_PKG too

So I do:

$ export GHC=ghc-6.12.1
$ export GHC_PKG=ghc-pkg-6.12.1

Then "bootstrap.sh" gets a bit further:

$ ./bootstrap.sh
Checking installed packages for ghc-6.12.1...

The Haskell package 'parsec' is required but it is not installed.
If you are using a ghc package provided by your operating system
then install the corresponding packages for 'parsec' and 'network'.
If you built ghc from source with only the core libraries then you
should install these extra packages. You can get them from hackage.

Error during cabal-install bootstrap:
The Haskell package 'parsec' is required but it is not installed.

I cannot install the appropriate libghc6-parsec-dev package from any Debian 
because they all require GHC =6.8.

> That, or wait until 6.12 is considered stable enough to become part of the
> Haskell platform.

How long will that take?

> For reference – I can quite believe that Haskell came out incredibly fast
> here – it's trivially easy to parallelise haskell programs, and GHC deals
> with parallelisation well (except for garbage collection unfortunately).

Yeah, I don't believe his Haskell is correct let alone fast. :-)

-- 
Dr Jon Harrop, Flying Frog Consultancy Ltd.
http://www.ffconsultancy.com/?e


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

Message: 4
Date: Fri, 15 Jan 2010 10:13:31 -0600
From: Antoine Latter <[email protected]>
Subject: Re: [Haskell-beginners] Haskell, Ray Tracing, Parallel
        Computation
To: Jon Harrop <[email protected]>
Cc: [email protected]
Message-ID:
        <[email protected]>
Content-Type: text/plain; charset=UTF-8

On Fri, Jan 15, 2010 at 11:24 AM, Jon Harrop <[email protected]> wrote:
> On Friday 15 January 2010 15:17:38 Tom Davie wrote:
>> You should be able to get it just by running cabal update & cabal install
>> AC-Vector.
>
> When I run "cabal install" it says:
>
> $ cabal update
> Downloading the latest package list from hackage.haskell.org
> Note: there is a new version of cabal-install available.
> To upgrade, run: cabal install cabal-install
>
> If I run "cabal install cabal-install" as it suggests then it appears to do a
> lot of work, ending with this:
>
> ...
> [33 of 34] Compiling Distribution.Client.List ( Distribution/Client/List.hs,
> dist/build/cabal/cabal-tmp/Distribution/Client/List.o )
> [34 of 34] Compiling Main             ( Main.hs,
> dist/build/cabal/cabal-tmp/Main.o )
> Linking dist/build/cabal/cabal ...
> Installing executable(s) in /home/jdh30/.cabal/bin
>
> But when I run "cabal install" again it fails to detect the updated
> cabal-install correctly:
>

Is /home/jdh30/.cabal/bin in your $PATH? That's the default install
location of executables by cabal-install.

What I usually do is a manual soft-link from ${HOME}/.cabal/bin/foo to
${HOME}/bin/foo for the programs which cabal installs that I would
like in my path. But I may be a bit quirky.

Antoine


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

Message: 5
Date: Fri, 15 Jan 2010 19:13:17 +0100
From: Christian Maeder <[email protected]>
Subject: [Haskell-beginners] Re: Haskell, Ray Tracing, Parallel
        Computation
To: Jon Harrop <[email protected]>
Cc: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=UTF-8

Jon Harrop schrieb:
> On Friday 15 January 2010 15:17:38 Tom Davie wrote:
>> You should be able to get it just by running cabal update & cabal install
>> AC-Vector.

http://hackage.haskell.org/package/AC-Vector
http://hackage.haskell.org/packages/archive/AC-Vector/1.1.1/AC-Vector-1.1.1.tar.gz

AC-Vector is a simple (single source) package only requiring the base
package, so even without "cabal-install" (that installs the "cabal"
binary) you should be able to download and unpack it:

  cd AC-Vector-1.1.1
  ghc --make Setup.hs
  ./Setup install --user
  ./Setup build
  ./Setup install

> When I run "cabal install" it says:
> 
> $ cabal update
> Downloading the latest package list from hackage.haskell.org
> Note: there is a new version of cabal-install available.
> To upgrade, run: cabal install cabal-install

I wonder which "cabal" binary was used? (from an old installation?)

> 
> If I run "cabal install cabal-install" as it suggests then it appears to do a 
> lot of work, ending with this:
> 
> ...
> [33 of 34] Compiling Distribution.Client.List ( Distribution/Client/List.hs, 
> dist/build/cabal/cabal-tmp/Distribution/Client/List.o )
> [34 of 34] Compiling Main             ( Main.hs, 
> dist/build/cabal/cabal-tmp/Main.o )
> Linking dist/build/cabal/cabal ...
> Installing executable(s) in /home/jdh30/.cabal/bin

So a new binary was installed in /home/jdh30/.cabal/bin. Check if

  /home/jdh30/.cabal/bin/cabal --version

shows

  cabal-install version 0.8.0
  using version 1.8.0.2 of the Cabal library

and replace your older cabal version (in your PATH).

If you still see an older version (of the Cabal library) you may need to
bootstrap cabal-install-0.8.0 and manually install parsec-2.1.0.1 and
network (i.e. version 2.2.1.5) before (as described above for AC-Vector).

Cheers Christian

P.S. If you add "--global" to "cabal install" binaries will be installed
under /usr/local/bin (and libraries in the global package.conf file)


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

Message: 6
Date: Fri, 15 Jan 2010 19:49:40 +0100
From: Luca Ciciriello <[email protected]>
Subject: [Haskell-beginners] using "read"
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii

Hi All.

in the function:

func :: String -> Int
func str = read str

An absolute beginner as i am, want to use "read" to convert a String in a Int, 
but I don't know how to protect my function func from an exception when str is 
not a number like "12A". How can I do?

Thanks in advance for any answer to this my simply question.

Luca.

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

Message: 7
Date: Fri, 15 Jan 2010 20:02:44 +0100
From: Iustin Pop <[email protected]>
Subject: Re: [Haskell-beginners] using "read"
To: Luca Ciciriello <[email protected]>
Cc: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii

On Fri, Jan 15, 2010 at 07:49:40PM +0100, Luca Ciciriello wrote:
> Hi All.
> 
> in the function:
> 
> func :: String -> Int
> func str = read str
> 
> An absolute beginner as i am, want to use "read" to convert a String
> in a Int, but I don't know how to protect my function func from an
> exception when str is not a number like "12A". How can I do?
> 
> Thanks in advance for any answer to this my simply question.

I have tried to solve this problem too, and I ended up using the
function "reads", which gives you back information about the parse
status.

Hope this helps,
iustin


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

_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners


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

Reply via email to