Re: [Haskell-cafe] Selecting Array type

2008-02-20 Thread Jeff φ
On 2/19/08, Ryan Ingram <[EMAIL PROTECTED]> wrote: > > Oleg's done a lot of work here; there's a bunch of magic that can be > done with TypeCast. I took my inspiration from here: > http://okmij.org/ftp/Haskell/typecast.html#ambiguity-resolution > . . . > > The trick is to represent whether a typ

[Haskell-cafe] Re: Selecting Array type

2008-02-19 Thread Jeff φ
I apologize if this has already been posted. I sent the following message several hours ago and I haven't seen it post. So, I'm resending. I'm trying to create a type called SmartArray. It is a type synonym for an array. If the element type can be unboxed, then SmartArray is an unboxed array.

[Haskell-cafe] Selecting Array type

2008-02-19 Thread Jeff φ
I'm trying to create a type called SmartArray. It is a type synonym for an array. If the element type can be unboxed, then SmartArray is an unboxed array. Otherwise, it is a boxed array. For instance, (SmartArray Int Double) is the same as (UArray Int Double) (SmartArray Int String) is the sam

Re: [Haskell-cafe] Help with error

2008-02-16 Thread Jeff φ
2008/2/15 Antoine Latter <[EMAIL PROTECTED]>: > (sent to the list this time) > > The problem is in the type-signature for from_seq: > > from_seq :: (Sequence seq) => (seq e) -> (t e) > > Neither the From_seq class or the type signature of the from_seq > function place any restrictions on the type

[Haskell-cafe] Help with error

2008-02-15 Thread Jeff φ
Hello, I get an error message on the code below with GHC. I can't figure out how to get rid of the error. I'd appreciate suggestions on how to fix this. (BTW, the code may look overly combersome because I stripped out anything unnecessary to demonstrate the error.) {-# OPTIONS_GHC -fglasgow

Re: [Haskell-cafe] Mutable arrays

2008-02-07 Thread Jeff φ
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 >>= r

Re: [Haskell-cafe] Mutable arrays

2008-02-06 Thread Jeff φ
> > 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 d

Re: [Haskell-cafe] Mutable arrays

2008-02-06 Thread Jeff φ
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 > > ar

Re: [Haskell-cafe] Mutable arrays

2008-02-06 Thread Jeff φ
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

Re: [Haskell-cafe] Mutable arrays

2008-02-06 Thread Jeff φ
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 i

Re: [Haskell-cafe] Mutable arrays

2008-02-05 Thread Jeff φ
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

Re: [Haskell-cafe] Mutable arrays

2008-02-05 Thread Jeff φ
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

Re: [Haskell-cafe] Mutable arrays

2008-02-05 Thread Jeff φ
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 becaus

[Haskell-cafe] Mutable arrays

2008-02-02 Thread Jeff φ
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 do