On Fri, Aug 10, 2007 at 04:00:01PM +0800, Hugh Perkins wrote: > On 8/10/07, Donald Bruce Stewart <[EMAIL PROTECTED]> wrote: > > > > It's using bit arrays. > > > > Well I'm a total Haskell newbie, and you're using Haskell to write > imperative code, so it's really hard for me to read, but looking at your > code, you have: > > (IOUArray Int Bool) -- an array of Bool > > Bool is a 32-bit value in Haskell AFAIK? (or possibly a machine-dependent > sized value, but certainly not a bit?)
Bool is 32 bits, but Don is using UArray. UArray is not parametric in the element type, which means it's less generally useful (no UArray of Complex Double, for instance), but conversely it is able to use more efficient representations depending on the type. from Data.Array.Base: instance MArray (STUArray s) Bool (ST s) where ... unsafeRead (STUArray _ _ marr#) (I# i#) = ST $ \s1# -> case readWordArray# marr# (bOOL_INDEX i#) s1# of { (# s2#, e# #) -> (# s2#, (e# `and#` bOOL_BIT i#) `neWord#` int2Word# 0# #) } ... Okay, you probably can't read that (it's too ugly for me to *want* to read it), but the use of and# should stand out. bOOL_BIT computes a bitmask, bOOL_INDEX divides by 8. Stefan
signature.asc
Description: Digital signature
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe