[Haskell-cafe] ANN: random-access-list-0.1

Stephan Friedrichs deduktionstheorem at web.de
Thu Jun 12 18:25:57 EDT 2008

Chris Smith wrote:
> Chaddaï Fouché wrote:
>> Given that this structure isn't lazy enough, I really don't see a
>> problem with using Int (any random access list with a size that needs an
>> Integer would blow the memory anyway...).
> Bad way to think about things.  The implications of using Int as the 
> result type of a function extend far beyond just storing the result 
> type.  They also include doing other computations that depend on the 
> result type, and with enough type inference, the broken Int type 
> propogates throughout the program.

I'd like not to be restricted to Int, but what's the proper way to do 
so? Just adding "genericFun = fromInteger . toInteger . fun" functions 
is just as bad as using Ints directly. What I need is something like a 
more general Ix class that is not limited to a fixed interval:

class Ix2 i where
	-- convert starting index and given index to an Int for internal
	-- representation
	toIndex   :: i -> i -> Int

	-- given an internal Int index and a starting index, return the
	-- representing index
	fromIndex :: Int -> i -> i

	-- translate a starting index and a number of elements into a
	-- size
	size      :: i -> Int -> i

This is meant to work with a starting-index and a given index, so that a 
list does not have to start at index 0. Is there something like this? Or 
is it somehow possible to use the existing Ix class to do that?



Früher hieß es ja: Ich denke, also bin ich.
Heute weiß man: Es geht auch so.

  - Dieter Nuhr

More information about the Haskell-Cafe mailing list