1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
|
(* Copyright (C) 2002-2006 Henry Cejtin, Matthew Fluet, Suresh
* Jagannathan, and Stephen Weeks.
*
* MLton is released under a HPND-style license.
* See the file MLton-LICENSE for details.
*)
functor MonoVectorArrayArray2Convert
(structure Vector: MONO_VECTOR
structure VectorSlice: MONO_VECTOR_SLICE
structure Array: MONO_ARRAY
structure ArraySlice: MONO_ARRAY_SLICE
structure Array2: MONO_ARRAY2
sharing type Vector.elem = VectorSlice.elem =
Array.elem = ArraySlice.elem =
Array2.elem
sharing type Vector.vector = VectorSlice.vector =
Array.vector = ArraySlice.vector =
Array2.vector
sharing type VectorSlice.slice = ArraySlice.vector_slice
sharing type Array.array = ArraySlice.array) :
sig
structure Vector: MONO_VECTOR_1997
structure Array: MONO_ARRAY_1997
structure Array2: MONO_ARRAY2_1997
sharing type Vector.elem = Array.elem = Array2.elem
sharing type Vector.vector = Array.Vector.vector = Array2.Vector.vector
end =
struct
fun shift1 f (_, s, _) = fn (i:int, x) => f (i + s, x)
fun shift2 f (_, s, _) = fn (i:int, x, y) => f (i + s, x, y)
structure V =
struct
open Vector
fun extract sl = VectorSlice.vector (VectorSlice.slice sl)
fun mapi f sl = VectorSlice.mapi (shift1 f sl) (VectorSlice.slice sl)
fun appi f sl = VectorSlice.appi (shift1 f sl) (VectorSlice.slice sl)
fun foldli f b sl = VectorSlice.foldli (shift2 f sl) b (VectorSlice.slice sl)
fun foldri f b sl = VectorSlice.foldri (shift2 f sl) b (VectorSlice.slice sl)
end
structure A =
struct
open Array
structure Vector = V
fun appi f sl = ArraySlice.appi (shift1 f sl) (ArraySlice.slice sl)
fun copy {src, si, len, dst, di} =
ArraySlice.copy {src = ArraySlice.slice (src, si, len),
dst = dst, di = di}
fun copyVec {src, si, len, dst, di} =
ArraySlice.copyVec {src = VectorSlice.slice (src, si, len),
dst = dst, di = di}
fun extract sl = ArraySlice.vector (ArraySlice.slice sl)
fun foldli f b sl = ArraySlice.foldli (shift2 f sl) b (ArraySlice.slice sl)
fun foldri f b sl = ArraySlice.foldri (shift2 f sl) b (ArraySlice.slice sl)
fun modifyi f sl = ArraySlice.modifyi (shift1 f sl) (ArraySlice.slice sl)
end
structure A2 =
struct
open Array2
structure Vector = V
end
structure Array = A
structure Vector = V
structure Array2 = A2
end
|