[Haskell-beginners] Haskell type Array a b

Kevin Van Horn kevin at ksvanhorn.com
Tue May 27 00:40:01 UTC 2014


On May 26, Brandon Allbery <allbery.b at gmail.com>  wrote:

> On Mon, May 26, 2014 at 5:12 PM, Kevin Van Horn <kevin at ksvanhorn.com> wrote:
> I'm looking on the Haskell 98 Report, and the definition of (==) for values of type Array a b looks wrong to me. Here is the definition given:
> 
>   a == a' = (assocs a == assocs a')
> 
> But this fails to account for the array length in each dimension; hence, if
> 
> Have you tested this?

Yes. For the arrays I defined I had assocs a = [ ], because the length in one dimension was equal to 0. So I had x == y but bounds x != bounds y.

> I think if you're looking for anything more precise, you need to switch to something that can't be represented in H'98 or even H'2010, namely arrays with the bounds in the type.

Why would you need that? Array equality could have been defined to be

  a1 == a2 = (bounds a1 == bounds a2) && (assocs a1 == assocs a2)

and I don't understand why this is not the definition.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20140526/cbe4f0b2/attachment.html>


More information about the Beginners mailing list