[MLton] Word<N>

Matthew Fluet fluet@cs.cornell.edu
Mon, 14 Mar 2005 14:36:53 -0500 (EST)

> I hope I am not missing something obvious but why is N > 1.  Why not implement
> Word1?  Binary arithmetic is universally useful... just now I was trying to
> write the code to compute a binary determinant of a binary matrix but alas
> Word1 is not there.  Maybe it was left out to keep it symmetric with the Int
> case when Int1 would not make much sence.  But word1 does...

I don't see any reason to rule out word1 (or int1, for that matter).  In
fact, it appears that the compiler handles word1; the primitive tycon
word1 is provided in the primitive environment and the rest of the
compiler is all nicely abstracted on word sizes.

Unfortunately, there seems to be a bug in the elaborator, because it does
not like

val t : Word1.word = 0wx1

Error: z.sml 14.5.
  Pattern and expression disagree.
    pattern:    [WordN.word]
    expression: [word]
    in: (t): Word1.word = 0wx1

although it happily accepts

val t : Word1.word = Word1.fromLarge 0wx1