[MLton-commit] r4354

Matthew Fluet MLton@mlton.org
Sun, 12 Feb 2006 10:36:59 -0800


Refactoring arrays-and-vectors
----------------------------------------------------------------------

A   mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/arrays-and-vectors/seq-index1.sml

----------------------------------------------------------------------

Added: mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/arrays-and-vectors/seq-index1.sml
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/arrays-and-vectors/seq-index1.sml	2006-02-12 18:36:38 UTC (rev 4353)
+++ mlton/branches/on-20050822-x86_64-branch/basis-library.refactor/arrays-and-vectors/seq-index1.sml	2006-02-12 18:36:59 UTC (rev 4354)
@@ -0,0 +1,46 @@
+(* Copyright (C) 1999-2005 Henry Cejtin, Matthew Fluet, Suresh
+ *    Jagannathan, and Stephen Weeks.
+ * Copyright (C) 1997-2000 NEC Research Institute.
+ *
+ * MLton is released under a BSD-style license.
+ * See the file MLton-LICENSE for details.
+ *)
+
+structure SeqIndex =
+   struct
+      open SeqIndex
+         
+      local
+         open Primitive
+         structure S =
+            SeqIndex_ChooseIntN
+            (type 'a t = IntInf.int -> 'a
+             val fInt8 = fn i => Word8.toInt8X (IntInf.toWord8X i)
+             val fInt16 = fn i => Word16.toInt16X (IntInf.toWord16X i)
+             val fInt32 = fn i => Word32.toInt32X (IntInf.toWord32X i)
+             val fInt64 = fn i => Word64.toInt64X (IntInf.toWord64X i))
+         structure S =
+            Int_ChooseInt
+            (type 'a t = 'a -> int
+             val fInt8 = fromInt8Unsafe
+             val fInt16 = fromInt16Unsafe
+             val fInt32 = fromInt32Unsafe
+             val fInt64 = fromInt64Unsafe
+             val fIntInf = S.f)
+      in
+         val fromIntUnsafe = S.f
+      end
+   
+      local
+         structure S =
+            Int_ChooseInt
+            (type 'a t = int -> 'a
+             val fInt8 = toInt8Unsafe
+             val fInt16 = toInt16Unsafe
+             val fInt32 = toInt32Unsafe
+             val fInt64 = toInt64Unsafe
+             val fIntInf = toIntInf)
+      in
+         val toIntUnsafe = S.f
+      end
+   end