[Haskell-cafe] Re: Block-wise lazy sequences in Haskell

Benjamin Franksen benjamin.franksen at bessy.de
Fri Sep 7 18:18:01 EDT 2007


Bryan O'Sullivan wrote:

> Henning Thielemann wrote:
> 
>>  I thought it must be possible to define an unboxed array type with 
>> Storable elements.
> 
> Yes, this just hasn't been done.  There would be a few potentially 
> tricky corners, of course; Storable instances are not required to be 
> fixed in size, 

They are (indirectly), see

http://www.haskell.org/ghc/docs/latest/html/libraries/base/Foreign-Storable.html#v%3AsizeOf

sizeOf :: a -> Int
  Computes the storage requirements (in bytes) of the argument. The value of
the argument is not used.

and http://www.cse.unsw.edu.au/~chak/haskell/ffi/ffi/ffise5.html#x8-320005.7

sizeOf    :: Storable a => a -> Int 
alignment :: Storable a => a -> Int 
 
 The function sizeOf computes the storage requirements (in bytes) of the
argument, andalignment computes the alignment constraint of the argument.
An alignment constraint x is fulfilled by any address divisible by x. Both
functions do not evaluate their argument, but compute the result on the
basis of the type of the argument alone. [...]

Cheers
Ben



More information about the Haskell-Cafe mailing list