Re: [Haskell-cafe] trivial function application question

2007-01-04 Thread J. Garrett Morris
Oops, I seem not to have proofread my message. On 1/4/07, J. Garrett Morris <[EMAIL PROTECTED]> wrote: On 1/4/07, brad clawsie <[EMAIL PROTECTED]> wrote: > s = "abcdefg" > patterns = ["a","b"] > replacements = ["Z","Y"] I changed the name here so as not to conflict with the replace function.

Re: [Haskell-cafe] trivial function application question

2007-01-04 Thread tphyahoo
So the core question (speaking as a perler) is how do you write my $s= 'abcdefg'; $s =~ s/a/z/g; $s =~ s/b/y/g; print "$s\n"; in haskell? There are various haskell regex libraries out there, including ones that advertise they are PCRE (Perl Compatible Reg Ex). But which one to use? H

[Haskell-cafe] Re: [Haskell] Re: state of HaXml?

2007-01-04 Thread Donald Bruce Stewart
nr: > > Sure, you can replace the openFile/hGetContents pair by readFile, but the > > real problem is the presence of the hClose. Removing that will solve your > > problem (but note that you now have no control over when the file is > > actually closed). > > Can I just leave it hanging and re

Re: [Haskell-cafe] Redefining superclass default methods in a subclass

2007-01-04 Thread Brian Hulley
Roberto Zunino wrote: Brian Hulley wrote: because Haskell doesn't allow a superclass (or ancestor class) method default to be redefined in a subclass. How one would write instances? Using your Monad class, does instance Monad F where return = ... (>>=) = ... automatically define

Re: [Haskell-cafe] MVar style question

2007-01-04 Thread Mike Gunter
Do you need to maintain invariants that span the two? Put operationally, do you want different threads to be able to access a and b concurrently? -m "Chad Scherrer" <[EMAIL PROTECTED]> writes: > When using MVars, is there a reason to prefer using MVar (a,b) over > (MVar a, MVar b), or vice ver

Re: [Haskell-cafe] Redefining superclass default methods in a subclass

2007-01-04 Thread Roberto Zunino
Brian Hulley wrote: Hi, Looking at some of the ideas in http://www.haskell.org/haskellwiki/The_Other_Prelude , it struck me that the class system at the moment suffers from the problem that as hierarchies get deeper, the programmer is burdened more and more by the need to cut-and-paste method

Re: [Haskell-cafe] trivial function application question

2007-01-04 Thread J. Garrett Morris
On 1/4/07, brad clawsie <[EMAIL PROTECTED]> wrote: lets say i have a string s = "abcdefg" now i have two lists of strings, one a list of patterns to match, and a list of replacement strings: patterns = ["a","b"] replace = ["Z","Y"] from which my intent is that "a" be replaced by "Z", "b" by "

Re: [Haskell-cafe] trivial function application question

2007-01-04 Thread Neil Mitchell
Hi Brad, i have a small problem that will be certainly trivial for almost everyone reading this, i would appreciate a little help If you have trivial problems, its often useful to ask on Haskell IRC (http://www.haskell.org/haskellwiki/IRC_channel) from which my intent is that "a" be replaced

[Haskell-cafe] trivial function application question

2007-01-04 Thread brad clawsie
greetings to this helpful and informative list i have a small problem that will be certainly trivial for almost everyone reading this, i would appreciate a little help lets say i have a string s = "abcdefg" now i have two lists of strings, one a list of patterns to match, and a list of replacem

Re: [Haskell-cafe] MVar style question

2007-01-04 Thread Roberto Zunino
Chad Scherrer wrote: When using MVars, is there a reason to prefer using MVar (a,b) over (MVar a, MVar b), or vice versa? No one is strictly better than the other. But there are practical implications of choosing between them. For instance, MVar (A,B) is less prone to deadlock issues than (M

Re: [Haskell-cafe] Re: Seeking advice on a style question

2007-01-04 Thread Steve Schafer
[Apologies for the long delay in replying; I've been traveling, etc.] On Sun, 31 Dec 2006 20:11:47 +0100, you wrote: >The other extreme is the one I favor: the whole pipeline is expressible >as a chain of function compositions via (.). One should be able to write > > process = rectangles2pages .

[Haskell-cafe] Redefining superclass default methods in a subclass

2007-01-04 Thread Brian Hulley
Hi, Looking at some of the ideas in http://www.haskell.org/haskellwiki/The_Other_Prelude , it struck me that the class system at the moment suffers from the problem that as hierarchies get deeper, the programmer is burdened more and more by the need to cut-and-paste method definitions between

[Haskell-cafe] MVar style question

2007-01-04 Thread Chad Scherrer
When using MVars, is there a reason to prefer using MVar (a,b) over (MVar a, MVar b), or vice versa? I'm not sure if this is really a question of style, or if there are practial implications I'm missing one way or another. Thanks! -- Chad Scherrer "Time flies like an arrow; fruit flies like a b

Re: [Haskell-cafe] Announce: Package rdtsc for reading IA-32 time stamp counters

2007-01-04 Thread Martin Grabmueller
Andy Georges schrieb: > Hi, > >> version 1.0 of package rdtsc has just been released. >> >> This small package contains one module called 'Rdtsc.Rdtsc'. > > I am wondering what it would take to get rdpmc in there as well. Of > course, you'd need some way to set the pmcs before running, but that c

Re: [Haskell-cafe] Haskell Weekly News: January 02, 2007

2007-01-04 Thread Henning Thielemann
On Tue, 2 Jan 2007, Donald Bruce Stewart wrote: >Dimensional: Statically checked physical dimensions. Björn Buckwalter >[4]announced version 0.1 of [5]Dimensional, a module for statically >checked physical dimensions. The module facilitates calculations with >physical quantities w

Re: [Haskell-cafe] Arrays performance

2007-01-04 Thread Chris Kuklewicz
Paolo Veronelli wrote: > Quoting Paolo Veronelli <[EMAIL PROTECTED]>: >> I paste new version in case you care give me some moe suggestion. > > > > import Data.Maybe > import Data.List > import Data.Array.Diff > > import System.Environment > import Control.Arrow > import Control.Monad > > impo

Re: [Haskell-cafe] Announce: Package rdtsc for reading IA-32 time stamp counters

2007-01-04 Thread Andy Georges
Hi, version 1.0 of package rdtsc has just been released. This small package contains one module called 'Rdtsc.Rdtsc'. I am wondering what it would take to get rdpmc in there as well. Of course, you'd need some way to set the pmcs before running, but that can be done using e.g. perfctr. I'

Re: [Haskell-cafe] Arrays performance

2007-01-04 Thread Paolo Veronelli
Quoting Paolo Veronelli <[EMAIL PROTECTED]>: > I paste new version in case you care give me some moe suggestion. import Data.Maybe import Data.List import Data.Array.Diff import System.Environment import Control.Arrow import Control.Monad import Random inc l i = l // [(i,l!i + 1)] switch l

Re: Re[2]: [Haskell-cafe] Composing functions with runST

2007-01-04 Thread Yitzchak Gale
Hi Bulat, I wrote: One is the confusion caused by the strange semantics to those not familiar with the theory... Like me, of course. The other is awkwardness in extending the capabilites of ST. For that, I would propose that the function "unsafeRunST" be added to the library. Bulat Zigansh

Re: [Haskell-cafe] Composing functions with runST

2007-01-04 Thread Yitzchak Gale
I wrote: Am I missing something? Yes! In reality, I do not need unsafeSTRef for this at all, using a type suggested earlier by Udo: stToState :: MonadState st m => (forall s. STRef s st -> ST s a) -> m a stToState f = do s <- get let (y, s') = runST (stm f s) put s' return y where

Re[2]: [Haskell-cafe] Composing functions with runST

2007-01-04 Thread Bulat Ziganshin
Hello Yitzchak, Thursday, January 4, 2007, 12:25:41 PM, you wrote: > The other is awkwardness in extending the capabilites > of ST. For that, I would propose that the function "unsafeRunST" > be added to the library. this function exists, but named unsafeIOtoST. IO and ST is exactly the same thi

[Haskell-cafe] Re: Composing functions with runST

2007-01-04 Thread apfelmus
Yitzchak Gale wrote: > Well, it turns out that using Data.Sequence or Data.IntMap > to shuffle a list becomes prohibitive if you might have > more than about 10^5 elements in your list. So in that > case you will need to use a mutable array, and you now > need ST. > [..] > >>> Wouldn't it be nice i

Re: [Haskell-cafe] Composing functions with runST

2007-01-04 Thread Yitzchak Gale
I wrote: Combining ST and MTL can be messy, even in this simple case. You will probably write something with a type like RandomGen g => [a] -> g -> ST s ([a], g) Udo Stenzel wrote: But why would you even want to do this? It's ugly and cumbersome. Yes indeed. You'd plug a runST in there an

[Haskell-cafe] Re: Composing functions with runST

2007-01-04 Thread apfelmus
Neil Mitchell wrote: > As for beginner issues with rank-2 types, I've been learning Haskell > for years now, and have never felt the need for a rank-2 type. If the > interface for some feature requires rank-2 types I'd call that an > abstraction leak in most cases. It certainly means that you can't

Re: [Haskell-cafe] Composing functions with runST

2007-01-04 Thread Yitzchak Gale
Paul Moore wrote: ...your nice helpful intuitions about monads can break down into real confusion when you hit complex monads, monad transformers and the like - *and you hit them quite early in the APIs of some libraries*! I don't think that is a problem with the design of the libraries. It is

Re: [Haskell-cafe] Composing functions with runST

2007-01-04 Thread Yitzchak Gale
Seth Gordon wrote: From a friendliness-to-newbies point of view, these error messages are a tremendous wart... Eeeww. Neil Mitchell wrote: If the interface for some feature requires rank-2 types I'd call that an abstraction leak in most cases. As the original poster of this thread, the one w

Re: [Haskell-cafe] Composing functions with runST

2007-01-04 Thread Paul Moore
On 1/3/07, Neil Mitchell <[EMAIL PROTECTED]> wrote: As for beginner issues with rank-2 types, I've been learning Haskell for years now, and have never felt the need for a rank-2 type. If the interface for some feature requires rank-2 types I'd call that an abstraction leak in most cases. It certa

Re: [Haskell-cafe] Composing functions with runST

2007-01-04 Thread Paul Moore
On 1/3/07, Seth Gordon <[EMAIL PROTECTED]> wrote: David House wrote: > >> So I can't just tell someone who's just starting to learn Haskell that >> "f $ g y" is equivalent to "f (g y)"; I have to say "those two are >> *almost always* equivalent, but if you use $ and the compiler complains >> abou