[MLton-user] Apparent bug in PackWord32Big.subVec
Matthew Fluet
fluet at tti-c.org
Thu Jun 21 20:23:32 PDT 2007
Ryan Newton wrote:
>
> The following code works in SML/NJ, but generates a type error in MLton.
>
> fun read_int32 vec i =
> Int32.fromLarge(Word32.toLargeInt(PackWord32Big.subVec(vec,0)))
>
>> From the error message, it looks like PackWord32Big.subVec is
> returning a Word64.word!
The Basis Library specifies that in the PACK_WORD signature,
val subVec : Word8Vector.vector * int -> LargeWord.word
In SML/NJ, LargeWord = Word32, but in MLton, LargeWord = Word64.
You should do the following:
fun read_int32 vec i =
Int32.fromLarge (LargeWord.toLargeInt (PackWord32Big.subVec (vec, 0)))
and use the LargeWord structure to convert.
More information about the MLton-user
mailing list