
I have a program which does a lot of computations with Array's of rationals. In order to get better performance I'd like to use unboxed arrays, but, since (Ratio Int) isn't a primitive type this doesn't work. It occured to me that I could rewrite this using -fglasgow-exts where I represent a rational by (# Int, Int #). It isn't too hard to do this, but I'd like to know it it's already in some library out there, so that I can use something already existing. This is a more general problem that I have (I'm pretty new to Haskell) of finding a library to "do X". Victor

You can use Data.Vector.Unboxed. There isn't an instance for Ratio a, but it is easy to write one, since it would be very similar to Complex a. http://hackage.haskell.org/packages/archive/vector/0.9.1/doc/html/Data-Vecto...

Also, uvector already supports unboxed Ratios: http://hackage.haskell.org/package/uvector In fact, I am surprised that Data.Vector doesn't have a Ratio instance, but has a Complex instance. Any ideas, why?

uvector is deprecated, its functionnalities has been ported into vector.
2012/1/11 Artyom Kazak
Also, uvector already supports unboxed Ratios: http://hackage.haskell.org/package/uvector
In fact, I am surprised that Data.Vector doesn't have a Ratio instance, but has a Complex instance. Any ideas, why?
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Yves Parès
uvector is deprecated, its functionnalities has been ported into vector.
Yes, but a Ratio a instance hasn't been ported. I admit that I have overlooked the “deprecated” warning, and agree that it is better to write an instance by yourself than use a deprecated package. Dead things should stay dead.

On 12/01/2012, at 21:01, Artyom Kazak wrote:
Yves Parès
писал(а) в своём письме Thu, 12 Jan 2012 13:14:16 +0200: uvector is deprecated, its functionnalities has been ported into vector.
Yes, but a Ratio a instance hasn't been ported.
FWIW, vector isn't a port of uvector in any sense, shape or form. Rather, uvector was a fork of a very old version of an internal DPH package, whereas vector is a from-scratch implementation of arrays based on the experience gained while working on DPH. Vector is an open-source project and has a trac. If you need something, open a ticket or better yet, send me patches! Emails sometimes work, too :-) Roman
participants (4)
-
Artyom Kazak
-
Roman Leshchinskiy
-
Victor Miller
-
Yves Parès