David Feuer david.fe...@gmail.com writes:
So I was thinking about a mutable array of tuples, but to avoid allocating
tuples to modify their fields, I guess I really want an immutable array of
tuples of STRefs. Just how much less efficient is this than a plain mutable
array? might it even make
In fact, unboxed arrays of tuples are represented in vector as tuples of
unboxed arrays.
On Aug 9, 2012 4:35 AM, Ketil Malde ke...@malde.org wrote:
David Feuer david.fe...@gmail.com writes:
So I was thinking about a mutable array of tuples, but to avoid
allocating
tuples to modify their
So I was thinking about a mutable array of tuples, but to avoid allocating
tuples to modify their fields, I guess I really want an immutable array of
tuples of STRefs. Just how much less efficient is this than a plain mutable
array? might it even make sense to use parallel mutable arrays? The
Stefan O'Rear wrote:
On Wed, Feb 06, 2008 at 08:57:43PM +, Andrew Butterfield wrote:
In Clean, we not only have explicit access to the world, but
we can partition it. Simplifying somewhat, we could open up
pairs of file-handle (f1.in,f1.out), (f2.in,f2,out) ... (fn.in,fn.out),
which does
Après avoir un peu manipulé la solution de John pour qu'elle fasse la même
chose que la mienne, je peux affirmer qu'elle est légèrement moins rapide
(c'est infime et normal vu que ses leftFold passent plus d'informations),
mais que les deux solutions ont au moins cet avantage d'être rapides (2s
Sorry for the french, I was a little bit confused...
On 08/02/08, Chaddaï Fouché [EMAIL PROTECTED] wrote :
After I changed John's code so that it worked on the same dataset as mine, I
could benchmark both of them :
My solution is a bit faster (but that's a very tiny difference and to be
expected
Hello Jeff,
Thursday, February 7, 2008, 1:31:59 AM, you wrote:
I noticed that
GHC implements mutable arrays in the IO monad. This seems odd to
me. Arrays aren't related to IO.
IO monad isn't only about I/O but about imperative stuff in general.
there is also special monad limited to
Hello Jeff,
Thursday, February 7, 2008, 4:17:27 AM, you wrote:
logical place for mutable arrays. However, I don't understand the
motivation for implementing it in IO. Were mutable arrays added to
IO because it would be difficult to write code that does both IO and
manipulates arrays
Ok, I've done some testing on different array accessing strategies,
and at this point I believe that, as Stefan previously suggested,
using an Oleg-inspired fold for access offers the best performance.
My first non-unsafe idea was to try:
import Data.Array.MArray
import Data.Array.IO
import
2008/2/7, Jeff φ [EMAIL PROTECTED]:
I played with your foldl1MArray' last night. I noticed it can be reduced to
. . .
foldl1MArray' :: (MArray a e m, Ix i) = (e - e - e) - a i e - m e
foldl1MArray' f a = do
(l,u) - getBounds a
foldl1' (liftM2 f) (map (readArray a) (range (l,u)))
On Feb 2, 2008 12:11 PM, Chaddaï Fouché [EMAIL PROTECTED] wrote:
To address this I propose this function :
foldl1MArray' :: (MArray a e m, Ix i) = (e - e - e) - a i e - m e
foldl1MArray' f a = do
(l,u) - getBounds a
firstElem - readArray a l
foldM (\a mb - a `seq` mb = return . f a)
On Feb 6, 2008 1:18 AM, Jonathan Cast [EMAIL PROTECTED] wrote:
On 5 Feb 2008, at 10:14 PM, Jeff φ wrote:
On Feb 5, 2008 4:58 PM, Chaddaï Fouché [EMAIL PROTECTED] wrote:
2008/2/5, Jeff φ [EMAIL PROTECTED]:
This is interesting. I've been programming in Concurrent Clean for a
while.
jeff1.61803:
On Feb 6, 2008 1:18 AM, Jonathan Cast [EMAIL PROTECTED]
wrote:
On 5 Feb 2008, at 10:14 PM, Jeff I* wrote:
On Feb 5, 2008 4:58 PM, ChaddaA- FouchA(c)
[EMAIL PROTECTED] wrote:
2008/2/5, Jeff I* [EMAIL PROTECTED]:
This is
That's a reasonable critique : its hard to enforce uniqueness, in the
type system in Haskell, -- I'd be interesting to see approaches that
avoid extending the compiler.
Isn't the compiler already modified in a way to deal with the RealWorld
type that is used in the IO monad? Surely the
On Feb 6, 2008, at 12:12 , Peter Verswyvelen wrote:
That's a reasonable critique : its hard to enforce uniqueness, in the
type system in Haskell, -- I'd be interesting to see approaches that
avoid extending the compiler.
Isn't the compiler already modified in a way to deal with the
On Feb 6, 2008, at 12:23 , Brandon S. Allbery KF8NH wrote:
You might want to look at the definition of unsafePerformIO before
asserting that.
On second thought I think I haven't had enough sleep to claim
anything of the sort with any confidence.
--
brandon s. allbery
Hi
Isn't the compiler already modified in a way to deal with the RealWorld
type that is used in the IO monad? Surely the RealWorld is unique...
No. The monad and the primitive operations ensure it is unique, the IO
monad is abstracted away properly, and it all works neatly so you
can't violate
; haskell-cafe@haskell.org
Subject: Re: [Haskell-cafe] Mutable arrays
Hi
Isn't the compiler already modified in a way to deal with the
RealWorld
type that is used in the IO monad? Surely the RealWorld is unique...
No. The monad and the primitive operations ensure it is unique, the IO
monad
On 2/6/08, Peter Verswyvelen [EMAIL PROTECTED] wrote:
Yeah, I also believed that, but then I'm confused:
So monads *do* enforce uniqueness... So what is the difference between
Haskell's monad approach and Clean's uniqueness typing? I always thought
these were just two different ways to
jeff1.61803:
On 2/6/08, Peter Verswyvelen [EMAIL PROTECTED] wrote:
Yeah, I also believed that, but then I'm confused:
So monads *do* enforce uniqueness... So what is the difference between
Haskell's monad approach and Clean's uniqueness typing? I always thought
2008/2/6, Jeff φ [EMAIL PROTECTED]:
I have solved both of these problems in Clean using a lazy list without
resorting to unsafe operations. So, it seems to me that uniqueness types
are more general than monads.
Are you aware that your code in Clean has some issues, like the lst
not being so
: Jeff φ [mailto:[EMAIL PROTECTED]
Sent: woensdag 6 februari 2008 20:21
To: Peter Verswyvelen; Neil Mitchell; Don Stewart
Cc: haskell-cafe@haskell.org
Subject: Re: [Haskell-cafe] Mutable arrays
On 2/6/08, Peter Verswyvelen [EMAIL PROTECTED] wrote:
Yeah, I also believed that, but then I'm
Peter Verswyvelen wrote:
So monads *do* enforce uniqueness... So what is the difference between
Haskell's monad approach and Clean's uniqueness typing? I always thought
these were just two different ways to tackle the same problem, and I had the
feeling Haskell's approach was actually more
Peter Verswyvelen wrote:
So you say uniqueness typing might be more general… Can one make list
monads and all the other funky Haskell monads with Clean’s uniqueness
typing then?
As my long post pointed out - as far IO is concerned, Clean is more
general than Haskell (less over-sequencing).
On Wed, Feb 06, 2008 at 08:57:43PM +, Andrew Butterfield wrote:
In Clean, we not only have explicit access to the world, but
we can partition it. Simplifying somewhat, we could open up
pairs of file-handle (f1.in,f1.out), (f2.in,f2,out) ... (fn.in,fn.out),
which does have to be done
On 2/6/08, Chaddaï Fouché [EMAIL PROTECTED] wrote:
2008/2/6, Jeff φ [EMAIL PROTECTED]:
I have solved both of these problems in Clean using a lazy list without
resorting to unsafe operations. So, it seems to me that uniqueness
types
are more general than monads.
Are you aware that your
Am Mittwoch, 6. Februar 2008 23:31 schrieb Jeff φ:
At the risk of starting a flame war, being labeled a troll, having Godwin's
law invoked, and suffering a life time ban from Haskell-Cafe, I'd like to
broach another subject. I noticed that GHC implements mutable arrays in
the IO monad. This
IO(U)Arrays are only one variant of mutable Array, there are also
ST(U)Arrays,
which are often preferred.
I should have worded my question better. The MArray interface is
implemented in both the ST and IO monad. A state monad seems like a logical
place for mutable arrays. However, I don't
On 6 Feb 2008, at 11:56 AM, Chaddaï Fouché wrote:
2008/2/6, Jeff φ [EMAIL PROTECTED]:
I have solved both of these problems in Clean using a lazy list
without
resorting to unsafe operations. So, it seems to me that
uniqueness types
are more general than monads.
Are you aware that your
On 6 Feb 2008, at 5:17 PM, Jeff φ wrote:
IO(U)Arrays are only one variant of mutable Array, there are also ST
(U)Arrays,
which are often preferred.
I should have worded my question better. The MArray interface is
implemented in both the ST and IO monad. A state monad seems like
a
I want to say thanks to everyone who responded to my mutable array post.
I'm going to work through and experiment with all the comments people
posted. It might take me a while.
Luke Palmer wrote:
Hmm, how big is the array? If it's pretty big, that's
understandable. Frankly, it's because
Jeff φ wrote:
Changing the subject slightly, I once wrote code in Concurrent Clean that
filtered a file that was larger than the available memory on my PC. I did
this by creating a function that returned the contents of the original file
as a lazy list.
Doing this is idiomatic in Haskell,
On Feb 5, 2008 4:36 PM, Jeff φ [EMAIL PROTECTED] wrote:
I want to say thanks to everyone who responded to my mutable array post.
I'm going to work through and experiment with all the comments people
posted. It might take me a while.
Luke Palmer wrote:
Hmm, how big is the array? If it's
Hello Jeff,
Tuesday, February 5, 2008, 7:36:27 PM, you wrote:
Changing the subject slightly, I once wrote code in Concurrent
Clean that filtered a file that was larger than the available memory
on my PC.
Is this possible with Monads in Haskell?
google for simple unix tools
--
Best
At least for file processing, I don't think the lazy solution is as
bad as some people on this list indicate. My solution was to define a
function processAudioFile :: (Handle, Handle) - (ASig - ASig) - IO
(), similar to interact. The function reads from the first handle and
writes to the second
On Tue, Feb 05, 2008 at 06:00:38PM -0600, John Lato wrote:
-- let ary_max = foldl1' max $ elems $ unsafeFreeze myArray
If you use a boxed array type (IOArray or STArray) for myArray, and
compiled with GHC, no copying is necessary (you may need to use type
annotations to guarantee this).
Hmm. It looks like I forgot a step, and it probably would segfault as
given. That's what I get for mucking about with unsafe* functions.
How about this?
let frozen_ary = unsafeFreeze myArray
let ary_max = foldl1' max $ elems frozen_ary
in ary_max `seq` map (1/ary_max) $ unsafeThaw frozen_ary
On Feb 5, 2008 4:58 PM, Chaddaï Fouché [EMAIL PROTECTED] wrote:
2008/2/5, Jeff φ [EMAIL PROTECTED]:
This is interesting. I've been programming in Concurrent Clean for a
while.
Instead of monads, Clean supports unique types for mutable arrays and
IO.
In Clean, I can write code that
I forgot to attach the source code for ArrayTest.icl
ArrayTest.icl
Description: Binary data
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
On 5 Feb 2008, at 10:14 PM, Jeff φ wrote:
On Feb 5, 2008 4:58 PM, Chaddaï Fouché [EMAIL PROTECTED]
wrote:
2008/2/5, Jeff φ [EMAIL PROTECTED]:
This is interesting. I've been programming in Concurrent Clean
for a while.
Instead of monads, Clean supports unique types for mutable
Hello,
I'm trying to write code that will take a mutable 2D array and normalize it
by dividing all elements by the largest element.
I managed to write code to do this, but it seems overly complex. I could
write something much simpler in Clean or C++. Most likely, my code is
complex because I
I prerequest your forgiveness if I sound patronizing, I'm just writing
everything that comes to mind.
2008/2/2 Jeff φ [EMAIL PROTECTED]:
{-# OPTIONS_GHC -fglasgow-exts -fbreak-on-exception #-}
-- normalize_ary This takes a mutable array. Determines the largest
-- element in the array
This is my attempt at some nicer code:
maximum' (x:xs) = foldl' max x xs
maximum' _ = undefined
modifyArray :: (MArray a e m, Ix i) = (e - e) - a i e - m ()
modifyArray fn arr = do
bounds - getBounds arr
forM_ (range bounds) (modifyElement fn arr)
modifyElement :: (MArray a e m, Ix i) =
Sorry, I was lazy. New maximum':
maximum' = foldl1' max
On 02/02/2008, Rodrigo Queiro [EMAIL PROTECTED] wrote:
This is my attempt at some nicer code:
maximum' (x:xs) = foldl' max x xs
maximum' _ = undefined
modifyArray :: (MArray a e m, Ix i) = (e - e) - a i e - m ()
modifyArray fn arr =
2008/2/2, Rodrigo Queiro [EMAIL PROTECTED]:
Sorry, I was lazy. New maximum':
maximum' = foldl1' max
Sorry but none of those propositions change the heart of the problem :
the list of elements is totally produced before she can be consumed
due to the strict monadic (IO or ST) nature of getElems.
On Sat, Feb 02, 2008 at 12:57:47PM +, Rodrigo Queiro wrote:
This is my attempt at some nicer code:
maximum' (x:xs) = foldl' max x xs
maximum' _ = undefined
modifyArray :: (MArray a e m, Ix i) = (e - e) - a i e - m ()
modifyArray fn arr = do
bounds - getBounds arr
forM_
On Sat, 2 Feb 2008, [ISO-8859-7] Jeff ö wrote:
Hello,
I'm trying to write code that will take a mutable 2D array and normalize it
by dividing all elements by the largest element.
Are you sure you need the arrays to be mutable? Maybe it's fast enough to
do the copying - it's significantly
47 matches
Mail list logo