Fwd: Re: [Haskell-cafe] more on the "Beautiful Concurrency" function "withdraw" application ...

2007-12-23 Thread Dean Herington
Date: Mon, 24 Dec 2007 01:44:16 -0500 To: "Galchin Vasili" <[EMAIL PROTECTED]>, haskell-cafe@haskell.org From: Dean Herington <[EMAIL PROTECTED]> Subject: Re: [Haskell-cafe] more on the "Beautiful Concurrency" function "withdraw" application ... Cc: Bcc: X-Attachments: At 12:19 AM -0600 12/24/0

Re: [Haskell-cafe] more on the "Beautiful Concurrency" function "withdraw" application ...

2007-12-23 Thread Dean Herington
At 12:19 AM -0600 12/24/07, Galchin Vasili wrote: module Main where import Control.Concurrent.STM import Control.Concurrent import System.Random type Account = TVar Int transfer :: Account -> Account -> Int -> IO () transfer from to amount = atomically (do {deposit to amount;

Re: [Haskell-cafe] Re: ANNOUNCE: GHC version 6.8.2

2007-12-23 Thread John Dorsey
Judah, Thanks for your reply, and your help. > > (Although it looks like the libraries/readline/configure script > > might recognize these, I can't get an option to pass through.) > > Actually, this is supposed to work. When running the top-level ghc > configure, you should be a

[Haskell-cafe] more on the "Beautiful Concurrency" function "withdraw" application ...

2007-12-23 Thread Galchin Vasili
module Main where import Control.Concurrent.STM import Control.Concurrent import System.Random type Account = TVar Int transfer :: Account -> Account -> Int -> IO () transfer from to amount = atomically (do {deposit to amount; withdraw from amount}) deposit :: Accou

[Haskell-cafe] Peyton Jones' "Beautiful Concurrency" .. i.e. Software Transactional Memory ...

2007-12-23 Thread Galchin Vasili
Hello, My brain is a "out to lunch". I have read the paper "Beautiful Concurrency" (as well as a bunch of "gaming" papers regarding multi cores). I am playing with the "Account" example in the paper. In the paper, the alias "type Account = TVar Int" is used. I want to actually apply the func

[Haskell-cafe] Gtk2Hs installation problem with ghc 6.8.2 on Ubuntu 7.10

2007-12-23 Thread Yin Wang
Hi, I'm installing Gtk2Hs on my Ubuntu 7.10. I have ghc 6.8.2 compiled with the extra libs in my home directory with the configuration "./configure --prefix=/home/wy/Programs" and it worked well. Then I configured gtk2hs in the same way and it compiled and installed with no problem. But when I tr

[Haskell-cafe] Gtk2HS and GHC 6.8.2

2007-12-23 Thread Peter Verswyvelen
It seems GHC 6.8.2 fixes a couple of bugs in GHC 6.8.1. Gtk2HS does not yet detect my GHC 6.8.2 installation, but I guess it is 100% compatible. Is it possible to get the Gtk2HS installer detect GHC 6.8.2? I'm on Windows. Thanks, Peter __

[Haskell-cafe] A question about functional dependencies

2007-12-23 Thread alpheccar
I have defined a function on types thanks to functional dependencies. I use it like that: myFunction :: (TypeFunction MyComplexType f) => f -> f f is unique for MyComplexType. Is there a way to name f ? I would like to write: myFunction :: SimplifiedType -> SimplifiedType where TypeFunction

Re: [Haskell-cafe] A Foldable binary search tree

2007-12-23 Thread Brad Larsen
On Sun, 23 Dec 2007 06:42:52 -0500, Neil Mitchell <[EMAIL PROTECTED]> wrote: Hi Brad, > Experience has taught me to _never_ put class contexts on data > definitions. Now you can't write something as simple as "Empty" - you > have to give it a class context. This is just plain annoying. With

Re: [Haskell-cafe] Comments on reading two ints off Bytestring

2007-12-23 Thread Bryan O'Sullivan
Paulo J. Matos wrote: > I guess the latter is the correct guess. Good guess! You can take advantage of the fact that the Maybe type is an instance of the Monad typeclass to chain those computations together, getting rid of all of the explicit case analysis. import qualified Data.ByteString.Char

Re: [Haskell-cafe] Comments on reading two ints off Bytestring

2007-12-23 Thread Neil Mitchell
Hi > > parseHeader $ BS.pack "hello 252 359" > (252,359) If this were strings, I'd start with: map read . words If you want to have error correction, I'd move to: mapM readMay . words (readMay comes from the safe package, http://www-users.cs.york.ac.uk/~ndm/safe/) I don't know about the byte

Re: [Haskell-cafe] Re: Comments on reading two ints off Bytestring

2007-12-23 Thread Brandon S. Allbery KF8NH
On Dec 23, 2007, at 7:35 , Paulo J. Matos wrote: parseHeader2 :: BS.ByteString -> (Int, Int) parseHeader2 bs = case (BS.readInt $ BS.dropWhile (not . isDigit) bs) of Nothing -> error "Couldn't find first natural." Just (x, rest) -> case (BS.readInt

Re: [Haskell-cafe] Re: Comments on reading two ints off Bytestring

2007-12-23 Thread Isaac Dupree
-- this should work too parseHeader3 :: BS.ByteString -> Maybe (Int, Int) --note accurate type signature, which helps us use Maybe failure-monad, --although losing your separate error messages parseHeader3 bs = do (x, rest) <- BS.readInt $ BS.dropWhile (not . isDigit) bs (y, _) <- BS.readInt

[Haskell-cafe] Re: Comments on reading two ints off Bytestring

2007-12-23 Thread Paulo J. Matos
On Dec 23, 2007 12:32 PM, Paulo J. Matos <[EMAIL PROTECTED]> wrote: > Hello all, > > It is either too difficult to get two integers of a bytestring, in > which case something should be done to ease the process or I should > learn much more Haskell. I guess the latter is the correct guess. > > I hav

[Haskell-cafe] Comments on reading two ints off Bytestring

2007-12-23 Thread Paulo J. Matos
Hello all, It is either too difficult to get two integers of a bytestring, in which case something should be done to ease the process or I should learn much more Haskell. I guess the latter is the correct guess. I have a bytestring containing two naturals. I was to get them as efficiently as poss

Re: [Haskell-cafe] Haskell performance

2007-12-23 Thread Ian Lynagh
On Thu, Dec 20, 2007 at 10:58:17AM +, Malcolm Wallace wrote: > > Nobench does already collect code size, but does not yet display it in > the results table. I specifically want to collect compile time as well. > Not sure what the best way to measure allocation and peak memory use > are? This

Re: [Haskell-cafe] A Foldable binary search tree

2007-12-23 Thread Neil Mitchell
Hi Brad, > > Experience has taught me to _never_ put class contexts on data > > definitions. Now you can't write something as simple as "Empty" - you > > have to give it a class context. This is just plain annoying. > > With the class context in the BST definition, ghc gives no complaints when > I