[Haskell-cafe] thread safety, IO arrays, and IO refs

2010-12-31 Thread Eric Stansifer
Hello, I wish to use a mutable array in multiple threads. Can IO arrays be used in any thread, or only the thread they are created in? (So if I create an IO array in one thread, pass it to another via an MVar, can I read / edit it in that other thread?) Similarly about IORefs... can they be

Re: [Haskell-cafe] thread safety, IO arrays, and IO refs

2010-12-31 Thread Antoine Latter
Have you tried it? Did you run in to any trouble? Assuming you get locking correct there shouldn't be any trouble with this. Take care, Antoine On Fri, Dec 31, 2010 at 4:19 AM, Eric Stansifer eric.stansifer+hask...@gmail.com wrote: Hello, I wish to use a mutable array in multiple threads.  

Re: [Haskell-cafe] thread safety, IO arrays, and IO refs

2010-12-31 Thread Edward Z. Yang
If you need multithreaded mutable arrays, TArray may be a better choice, as the underlying stm implementation will manage locking for you. (The current implementation isn't terribly efficient, but when it gets better you'll get it for free too :-)

[Haskell-cafe] Newbie Question

2010-12-31 Thread Chionidis Ioannis
Hello everybody! I am quite new to haskell programming. I am trying to make a gui for a drumming project made in euterpea and I want to do something like this : b - button f [text := Run! , on command := (test mambo_orig)] test mambo_orig is executed from ghci but I want It to be able to

Re: [Haskell-cafe] thread safety, IO arrays, and IO refs

2010-12-31 Thread Eric Stansifer
I tried a quick test with an IOArray, so I know that at least one time it works. I don't know enough of the internals of IO and IOArray to be able to extrapolate; there could be some race condition hidden internally if IO is misused. Thanks, Eric ___

Re: [Haskell-cafe] Newbie Question

2010-12-31 Thread Henk-Jan van Tuyl
On Fri, 31 Dec 2010 12:32:06 +0100, Chionidis Ioannis j...@echidna-band.com wrote: Hello everybody! I am quite new to haskell programming. I am trying to make a gui for a drumming project made in euterpea and I want to do something like this : b - button f [text := Run! , on command :=

[Haskell-cafe] Happy Parser problem

2010-12-31 Thread Aaron Gray
I am trying to get a grammar where keywords are also valid identifiers. Been messing round with the following Happy grammar :- %token 'let' { TokenIdent let } 'in'{ TokenIdent in } ident { TokenIdent $$ } int { TokenInt $$ }

Re: [Haskell-cafe] A question regarding cmdargs package

2010-12-31 Thread Sönke Hahn
On Thursday, December 30, 2010 06:50:32 pm Neil Mitchell wrote: Hi Sönke, I've just released cmdargs-0.6.6 which supports helpArgs [groupname Something] That was fast! Thanks a lot, works like a charm. Thanks, Sönke ___ Haskell-Cafe mailing list

Re: [Haskell-cafe] Happy Parser problem

2010-12-31 Thread Aaron Gray
On 31 December 2010 13:21, Aaron Gray aaronngray.li...@gmail.com wrote: I am trying to get a grammar where keywords are also valid identifiers. Sorry working now ! Aaron Been messing round with the following Happy grammar :- %token 'let' { TokenIdent let } 'in'

[Haskell-cafe] Many broken links

2010-12-31 Thread Henk-Jan van Tuyl
L.S., I find, quite often, links to haskell.org/xxx pages that have disappeared; isn't it possible to just copy all of these pages, to the original location, before the old server disappears? I used the W3C link checker[0] to check links from the GUI libraries page[1]; the following

Re: [Haskell-cafe] Deep concatenation [Was: Incorrectly inferring type [t]]

2010-12-31 Thread Iavor Diatchki
Hello, I just noticed that the instances for this example look more readable when written with two recently proposed Haskell extensions. Perhaps we should consider implementing these in GHC? Using chain instances: (http://web.cecs.pdx.edu/~mpj/pubs/instancechains.pdf ) instance DeepFlat a b =

Re: [Haskell-cafe] V.I.P.s and the associativity of merge'

2010-12-31 Thread Heinrich Apfelmus
Will Ness wrote: Heinrich Apfelmus writes: Here an example where the VIP merge would give a different result bad = tfold $ (1:10:undefined) : (2:3:5:undefined) : (4:undefined) : error bad We have ghci bad [1,2*** Exception: bad but the VIP version would give

Re: [Haskell-cafe] V.I.P.s and the associativity of merge'

2010-12-31 Thread Heinrich Apfelmus
Will Ness wrote: Heinrich Apfelmus writes: Here an example where the VIP merge would give a different result bad = tfold $ (1:10:undefined) : (2:3:5:undefined) : (4:undefined) : error bad We have ghci bad [1,2*** Exception: bad but the VIP version would give

[Haskell-cafe] Haskell Weekly News: Issue 163 - Year End Issue

2010-12-31 Thread Daniel Santa Cruz
Welcome to issue 163 of the HWN, a newsletter covering developments in the [1]Haskell community. This release of the newsletter contains some summary data for the year 2010. Thanks to everyone involved for making this such a wonderful community! Big cheers to Miran Lipovaa, who got

[Haskell-cafe] getting last char of String

2010-12-31 Thread Aaron Gray
Is there an easy Haskell function that gets the last Char of a [Char] or String ? Many thanks in advance, Aaron ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: [Haskell-cafe] getting last char of String

2010-12-31 Thread aditya siram
-- untested and won't work on an infinite list last :: [a] - a last = head . reverse -deech On Fri, Dec 31, 2010 at 2:39 PM, Aaron Gray aaronngray.li...@gmail.com wrote: Is there an easy Haskell function that gets the last Char of a [Char] or String ? Many thanks in advance, Aaron

Re: [Haskell-cafe] getting last char of String

2010-12-31 Thread Matthew Steele
Sounds like you're looking for `last', which is in the Prelude. http://www.haskell.org/ghc/docs/6.12.2/html/libraries/base-4.2.0.1/Prelude.html#v%3Alast Cheers, -Matt On Dec 31, 2010, at 3:39 PM, Aaron Gray wrote: Is there an easy Haskell function that gets the last Char of a [Char] or

Re: [Haskell-cafe] getting last char of String

2010-12-31 Thread Luke Palmer
http://haskell.org/hoogle/?hoogle=[Char]+-%3E+Char last looks conspicuous :-) On Fri, Dec 31, 2010 at 1:39 PM, Aaron Gray aaronngray.li...@gmail.com wrote: Is there an easy Haskell function that gets the last Char of a [Char] or String ? Many thanks in advance, Aaron

Re: [Haskell-cafe] getting last char of String

2010-12-31 Thread Aaron Gray
On 31 December 2010 20:44, Matthew Steele mdste...@alum.mit.edu wrote: Sounds like you're looking for `last', which is in the Prelude. Yep, feeling dumb I did not try it ! Thanks, Aaron http://www.haskell.org/ghc/docs/6.12.2/html/libraries/base-4.2.0.1/Prelude.html#v%3Alast Cheers,

[Haskell-cafe] Could someone give me a small code review

2010-12-31 Thread Aaron Gray
I have attached a tiny parser and lexer. This is really key to getting the lexing correct. The only thing I could not get neatly was to disallow hyphens at the end of identifiers, so have left it off until a good solution arrives. I plan to move over to monads next. Any comments welcome,

Re: [Haskell-cafe] getting last char of String

2010-12-31 Thread Felipe Almeida Lessa
On Fri, Dec 31, 2010 at 6:43 PM, aditya siram aditya.si...@gmail.com wrote: -- untested and won't work on an infinite list last :: [a] - a last = head . reverse No definition for last works with infinite lists =). Cheers, -- Felipe. ___

Re: [Haskell-cafe] Could someone give me a small code review

2010-12-31 Thread Edward Amsden
Only the parser was attached. On Fri, Dec 31, 2010 at 4:26 PM, Aaron Gray aaronngray.li...@gmail.com wrote: I have attached a tiny parser and lexer. This is really key to getting the lexing correct. The only thing I could not get neatly was to disallow hyphens at the end of identifiers, so

Re: [Haskell-cafe] Could someone give me a small code review

2010-12-31 Thread Aaron Gray
On 31 December 2010 21:26, Aaron Gray aaronngray.li...@gmail.com wrote: I have attached a tiny parser and lexer. This is really key to getting the lexing correct. The only thing I could not get neatly was to disallow hyphens at the end of identifiers, so have left it off until a good