[MLton-commit] r4731
Vesa Karvonen
vesak at mlton.org
Thu Oct 19 07:14:17 PDT 2006
Added toPoly, fromPoly, and polyIso specs/values to mono array and mono
vector modules. Note that the array conversions should probably always
make a copy for consistency across compilers, while the vector conversions
could be safely optimized to identity on compilers (like MLton) that make
it possible.
----------------------------------------------------------------------
U mltonlib/trunk/com/ssh/extended-basis/unstable/mk-mono-array-ext.fun
U mltonlib/trunk/com/ssh/extended-basis/unstable/mk-mono-vector-ext.fun
U mltonlib/trunk/com/ssh/extended-basis/unstable/mono-array.sig
U mltonlib/trunk/com/ssh/extended-basis/unstable/mono-vector.sig
----------------------------------------------------------------------
Modified: mltonlib/trunk/com/ssh/extended-basis/unstable/mk-mono-array-ext.fun
===================================================================
--- mltonlib/trunk/com/ssh/extended-basis/unstable/mk-mono-array-ext.fun 2006-10-19 13:52:06 UTC (rev 4730)
+++ mltonlib/trunk/com/ssh/extended-basis/unstable/mk-mono-array-ext.fun 2006-10-19 14:14:14 UTC (rev 4731)
@@ -20,5 +20,8 @@
fun fromVector v =
tabulate (MonoVector.length v, fn i => MonoVector.sub (v, i))
val vectorIso = (toVector, fromVector)
+ fun toPoly a = Array.tabulate (length a, fn i => sub (a, i))
+ fun fromPoly a = tabulate (Array.length a, fn i => Array.sub (a, i))
+ val polyIso = (toPoly, fromPoly)
end
Modified: mltonlib/trunk/com/ssh/extended-basis/unstable/mk-mono-vector-ext.fun
===================================================================
--- mltonlib/trunk/com/ssh/extended-basis/unstable/mk-mono-vector-ext.fun 2006-10-19 13:52:06 UTC (rev 4730)
+++ mltonlib/trunk/com/ssh/extended-basis/unstable/mk-mono-vector-ext.fun 2006-10-19 14:14:14 UTC (rev 4731)
@@ -13,4 +13,8 @@
open M
fun toList v = foldr op :: [] v
val listIso = (toList, fromList)
+ (* XXX It would be nice to avoid copying in toPoly and fromPoly *)
+ fun toPoly v = Vector.tabulate (length v, fn i => sub (v, i))
+ fun fromPoly v = tabulate (Vector.length v, fn i => Vector.sub (v, i))
+ val polyIso = (toPoly, fromPoly)
end
Modified: mltonlib/trunk/com/ssh/extended-basis/unstable/mono-array.sig
===================================================================
--- mltonlib/trunk/com/ssh/extended-basis/unstable/mono-array.sig 2006-10-19 13:52:06 UTC (rev 4730)
+++ mltonlib/trunk/com/ssh/extended-basis/unstable/mono-array.sig 2006-10-19 14:14:14 UTC (rev 4731)
@@ -16,4 +16,7 @@
val toVector : array -> vector
val fromVector : vector -> array
val vectorIso : (array, vector) iso
+ val toPoly : array -> elem Array.array
+ val fromPoly : elem Array.array -> array
+ val polyIso : (array, elem Array.array) iso
end
Modified: mltonlib/trunk/com/ssh/extended-basis/unstable/mono-vector.sig
===================================================================
--- mltonlib/trunk/com/ssh/extended-basis/unstable/mono-vector.sig 2006-10-19 13:52:06 UTC (rev 4730)
+++ mltonlib/trunk/com/ssh/extended-basis/unstable/mono-vector.sig 2006-10-19 14:14:14 UTC (rev 4731)
@@ -11,6 +11,9 @@
signature MONO_VECTOR =
sig
include MONO_VECTOR
+ val toList : vector -> elem list
val listIso : (vector, elem list) iso
- val toList : vector -> elem list
+ val toPoly : vector -> elem Vector.vector
+ val fromPoly : elem Vector.vector -> vector
+ val polyIso : (vector, elem Vector.vector) iso
end
More information about the MLton-commit
mailing list