Fast Mutable arrays and a general question about IO
Fri, 02 May 2003 16:21:52 -0500
Ron de Bruijn <firstname.lastname@example.org> wrote:
> > Why? It's not always necessary to go for maximum speed; do you have
> > a reason for needing it in this case?
> Almost any operation in my program works on array's and before the
> program terminates, there have been an awful lot of operations on
> it. If there is an other kind of array that mutates and doesn't create
> a copy of it when changing a value and isn't more than 1,5 times as
> slow as an array in C++ then that should also be ok. The program would
> run in a scale of hours or days. And if it's twice as fast, than I
> could calculate two times as much.
> > I think you mean `above'. In any case, could you show us some code
> > you have that's not working? That'll make it much easier for us to
> > answer your questions.
> Well I don't have really code, because I want to begin programming it.
> I will restate my goal: I want to be able to read, update and create
> arrays in Haskell of type myDataType (suppose my constructor function
> is Con Int String Int)
Alright. You seem to have the concepts down here, so I would recommend
you try to start on your own, and mail us back when you have a problem.
> on a way that's fast, preferabily the fastest method.
I don't know what the fastest method is, although I doubt you'll get
anything (natively) faster than IOArray, or IOUArray if you only need
arrays of primitive types.
> > > So to put it more concrete: In any Haskell program that does IO
> > > there is always some function that has this form:
> > >
> > > do x<-someSource
> > > putBoundVariableToSomeOtherFunctionThatDoesMonadicOperations
> > > (restOfPureFunctionalProgramForExample x)
> > No.
> Why not?
Sorry; I put that reply in the wrong place; I meant it to refer to the
item below it (meaning it's not possible to do IO within a value of type
Int). You are correct that there must be a function in any program with
/at least/ that form (i.e., there could be more statements, but if you
want to do processing within pure Haskell, you need to wrap that
processing ultimately roughly as shown above).