[Haskell-cafe] Specify array or list size?
glynn at gclements.plus.com
Sat May 7 16:42:23 EDT 2005
Daniel Carrera wrote:
> Right now I'm using type declarations like:
> f :: Int -> [Int]
> So f returns a list of Ints.
> Is there a way to tell Haskell that a list or array must have exactly
> (say) 256 elements? I'd love to have Haskell make sure that the array I
> build is the correct size.
For lists, no. For arrays, in the general case, again no. For your
specific case, you can use an array whose indices have type Word8 (8
bit unsigned integer), i.e.
type ByteMap = Array Word8 Word8
For an RC4 implementation, you should probably be using Word8
throughout rather than Int or Integer.
Glynn Clements <glynn at gclements.plus.com>
More information about the Haskell-Cafe