[MLton-commit] r4730
Vesa Karvonen
vesak at mlton.org
Thu Oct 19 06:52:09 PDT 2006
Added Iso/Emb -suffix to iso/emb values as suggested by Stephen Weeks.
Added toVector, fromVector, and vectorIso specs/values to array modules.
Note that ARRAY and MONO_ARRAY already specify a vector value.
Reorganized basis.mlb.
----------------------------------------------------------------------
U mltonlib/trunk/com/ssh/extended-basis/unstable/array.sml
U mltonlib/trunk/com/ssh/extended-basis/unstable/basis.mlb
U mltonlib/trunk/com/ssh/extended-basis/unstable/char.sig
U mltonlib/trunk/com/ssh/extended-basis/unstable/int-inf.sig
U mltonlib/trunk/com/ssh/extended-basis/unstable/integer.sig
U mltonlib/trunk/com/ssh/extended-basis/unstable/mk-integer-ext.fun
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/mk-real-ext.fun
U mltonlib/trunk/com/ssh/extended-basis/unstable/mk-text-ext.fun
U mltonlib/trunk/com/ssh/extended-basis/unstable/mk-word-ext.fun
U mltonlib/trunk/com/ssh/extended-basis/unstable/mono-array.sig
U mltonlib/trunk/com/ssh/extended-basis/unstable/mono-arrays-mlton.sml
U mltonlib/trunk/com/ssh/extended-basis/unstable/mono-vector.sig
U mltonlib/trunk/com/ssh/extended-basis/unstable/real.sig
U mltonlib/trunk/com/ssh/extended-basis/unstable/string.sig
U mltonlib/trunk/com/ssh/extended-basis/unstable/vector.sml
U mltonlib/trunk/com/ssh/extended-basis/unstable/word.sig
----------------------------------------------------------------------
Modified: mltonlib/trunk/com/ssh/extended-basis/unstable/array.sml
===================================================================
--- mltonlib/trunk/com/ssh/extended-basis/unstable/array.sml 2006-10-19 09:31:43 UTC (rev 4729)
+++ mltonlib/trunk/com/ssh/extended-basis/unstable/array.sml 2006-10-19 13:52:06 UTC (rev 4730)
@@ -11,13 +11,19 @@
signature ARRAY =
sig
include ARRAY
- val list : ('a array, 'a list) iso
val toList : 'a array -> 'a list
+ val listIso : ('a array, 'a list) iso
+ val toVector : 'a array -> 'a vector
+ val fromVector : 'a vector -> 'a array
+ val vectorIso : ('a array, 'a vector) iso
end
structure Array : ARRAY =
struct
open Array
fun toList v = foldr op :: [] v
- val list = (toList, fromList)
+ val listIso = (toList, fromList)
+ val toVector = vector
+ fun fromVector v = tabulate (Vector.length v, fn i => Vector.sub (v, i))
+ val vectorIso = (toVector, fromVector)
end
Modified: mltonlib/trunk/com/ssh/extended-basis/unstable/basis.mlb
===================================================================
--- mltonlib/trunk/com/ssh/extended-basis/unstable/basis.mlb 2006-10-19 09:31:43 UTC (rev 4729)
+++ mltonlib/trunk/com/ssh/extended-basis/unstable/basis.mlb 2006-10-19 13:52:06 UTC (rev 4730)
@@ -10,38 +10,62 @@
"warnUnused true"
in
$(SML_LIB)/basis/basis.mlb
+
+ (* New {Iso :> ISO} and {Emb :> EMB} modules *)
iso.sml
emb.sml
+
+ (* Extended integer modules *)
local
mk-integer-ext.fun
- mk-mono-array-ext.fun
- mk-mono-vector-ext.fun
- mk-real-ext.fun
- mk-word-ext.fun
-
mk-int-inf-ext.fun
-
- mk-text-ext.fun
in
- char.sig
int-inf.sig
integer.sig
- mono-array.sig
- mono-vector.sig
+ ints-mlton.sml
+ end
+
+ (* Extended real modules *)
+ local
+ mk-real-ext.fun
real.sig
- string.sig
+ in
+ reals-mlton.sml
+ end
+
+ (* Extended word modules *)
+ local
+ mk-word-ext.fun
+ in
word.sig
+ words-mlton.sml
+ end
- text.sig
-
- array.sml
- ints-mlton.sml
- mono-arrays-mlton.sml
+ (* Extended vector modules *)
+ local
+ mk-mono-vector-ext.fun
+ in
+ mono-vector.sig
mono-vectors-mlton.sml
- reals-mlton.sml
vector.sml
- words-mlton.sml
- texts-mlton.sml
+ (* Extended array modules (may depend on vector modules) *)
+ local
+ mk-mono-array-ext.fun
+ in
+ mono-array.sig
+ array.sml
+ mono-arrays-mlton.sml
+
+ (* Extended text modules (may depend on vector and array modules) *)
+ local
+ mk-text-ext.fun
+ in
+ char.sig
+ string.sig
+ text.sig
+ texts-mlton.sml
+ end
+ end
end
end
Modified: mltonlib/trunk/com/ssh/extended-basis/unstable/char.sig
===================================================================
--- mltonlib/trunk/com/ssh/extended-basis/unstable/char.sig 2006-10-19 09:31:43 UTC (rev 4729)
+++ mltonlib/trunk/com/ssh/extended-basis/unstable/char.sig 2006-10-19 13:52:06 UTC (rev 4730)
@@ -11,7 +11,7 @@
signature CHAR =
sig
include CHAR
- val int : (char, Int.int) iso
+ val intIso : (char, Int.int) iso
val minOrd : Int.int
val boundsChar : char * char
val boundsOrd : Int.int * Int.int
Modified: mltonlib/trunk/com/ssh/extended-basis/unstable/int-inf.sig
===================================================================
--- mltonlib/trunk/com/ssh/extended-basis/unstable/int-inf.sig 2006-10-19 09:31:43 UTC (rev 4729)
+++ mltonlib/trunk/com/ssh/extended-basis/unstable/int-inf.sig 2006-10-19 13:52:06 UTC (rev 4730)
@@ -11,9 +11,9 @@
signature INT_INF =
sig
include INT_INF
- val int : (int, Int.int) iso
- val large : (int, LargeInt.int) iso
- val string : (int, string) emb
+ val intIso : (int, Int.int) iso
+ val largeIso : (int, LargeInt.int) iso
+ val stringEmb : (int, string) emb
val isZero : int -> bool
val isEven : int -> bool
val isOdd : int -> bool
Modified: mltonlib/trunk/com/ssh/extended-basis/unstable/integer.sig
===================================================================
--- mltonlib/trunk/com/ssh/extended-basis/unstable/integer.sig 2006-10-19 09:31:43 UTC (rev 4729)
+++ mltonlib/trunk/com/ssh/extended-basis/unstable/integer.sig 2006-10-19 13:52:06 UTC (rev 4730)
@@ -11,9 +11,9 @@
signature INTEGER =
sig
include INTEGER
- val int : (int, Int.int) iso
- val large : (int, LargeInt.int) iso
- val string : (int, string) emb
+ val intIso : (int, Int.int) iso
+ val largeIso : (int, LargeInt.int) iso
+ val stringEmb : (int, string) emb
val isZero : int -> bool
val isEven : int -> bool
val isOdd : int -> bool
Modified: mltonlib/trunk/com/ssh/extended-basis/unstable/mk-integer-ext.fun
===================================================================
--- mltonlib/trunk/com/ssh/extended-basis/unstable/mk-integer-ext.fun 2006-10-19 09:31:43 UTC (rev 4729)
+++ mltonlib/trunk/com/ssh/extended-basis/unstable/mk-integer-ext.fun 2006-10-19 13:52:06 UTC (rev 4730)
@@ -11,9 +11,9 @@
functor MkIntegerExt (I : INTEGER) =
struct
open I
- val int = (toInt, fromInt)
- val large = (toLarge, fromLarge)
- val string = (toString, fromString)
+ val intIso = (toInt, fromInt)
+ val largeIso = (toLarge, fromLarge)
+ val stringEmb = (toString, fromString)
fun isZero i = fromInt 0 = i
fun isEven i = isZero (rem (i, fromInt 2))
val isOdd = not o isEven
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 09:31:43 UTC (rev 4729)
+++ mltonlib/trunk/com/ssh/extended-basis/unstable/mk-mono-array-ext.fun 2006-10-19 13:52:06 UTC (rev 4730)
@@ -8,9 +8,17 @@
* Functor for extending {MONO_ARRAY} modules.
*)
-functor MkMonoArrayExt (M : MONO_ARRAY) =
+functor MkMonoArrayExt (structure MonoVector : MONO_VECTOR
+ structure MonoArray : MONO_ARRAY
+ where type elem = MonoVector.elem
+ where type vector = MonoVector.vector) =
struct
- open M
- fun toList v = foldr op :: [] v
- val list = (toList, fromList)
+ open MonoArray
+ fun toList a = foldr op :: [] a
+ val listIso = (toList, fromList)
+ val toVector = vector
+ fun fromVector v =
+ tabulate (MonoVector.length v, fn i => MonoVector.sub (v, i))
+ val vectorIso = (toVector, fromVector)
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 09:31:43 UTC (rev 4729)
+++ mltonlib/trunk/com/ssh/extended-basis/unstable/mk-mono-vector-ext.fun 2006-10-19 13:52:06 UTC (rev 4730)
@@ -12,5 +12,5 @@
struct
open M
fun toList v = foldr op :: [] v
- val list = (toList, fromList)
+ val listIso = (toList, fromList)
end
Modified: mltonlib/trunk/com/ssh/extended-basis/unstable/mk-real-ext.fun
===================================================================
--- mltonlib/trunk/com/ssh/extended-basis/unstable/mk-real-ext.fun 2006-10-19 09:31:43 UTC (rev 4729)
+++ mltonlib/trunk/com/ssh/extended-basis/unstable/mk-real-ext.fun 2006-10-19 13:52:06 UTC (rev 4730)
@@ -11,10 +11,10 @@
functor MkRealExt (R : REAL) =
struct
open R
- val decimal = (toDecimal, fromDecimal)
- val int = (toInt IEEEReal.TO_NEAREST, fromInt)
- val large = (toLarge, fromLarge IEEEReal.TO_NEAREST)
- val largeInt = (toLargeInt IEEEReal.TO_NEAREST, fromLargeInt)
- val manExp = (toManExp, fromManExp)
- val string = (toString, fromString)
+ val decimalEmb = (toDecimal, fromDecimal)
+ val intIso = (toInt IEEEReal.TO_NEAREST, fromInt)
+ val largeIso = (toLarge, fromLarge IEEEReal.TO_NEAREST)
+ val largeIntIso = (toLargeInt IEEEReal.TO_NEAREST, fromLargeInt)
+ val manExpIso = (toManExp, fromManExp)
+ val stringEmb = (toString, fromString)
end
Modified: mltonlib/trunk/com/ssh/extended-basis/unstable/mk-text-ext.fun
===================================================================
--- mltonlib/trunk/com/ssh/extended-basis/unstable/mk-text-ext.fun 2006-10-19 09:31:43 UTC (rev 4729)
+++ mltonlib/trunk/com/ssh/extended-basis/unstable/mk-text-ext.fun 2006-10-19 13:52:06 UTC (rev 4730)
@@ -15,20 +15,22 @@
structure Char =
struct
open Char
- val int = (ord, chr)
+ val intIso = (ord, chr)
val minOrd = 0
val boundsChar = (minChar, maxChar)
val boundsOrd = (minOrd, maxOrd)
end
- structure CharArray = MkMonoArrayExt (CharArray)
structure CharVector = MkMonoVectorExt (CharVector)
+ structure CharArray =
+ MkMonoArrayExt (structure MonoArray = CharArray
+ structure MonoVector = CharVector)
structure String =
struct
open CharVector String
- val list = (explode, implode)
- val cString = (toCString, fromCString)
- val string = (toString, fromString)
+ val listIso = (explode, implode)
+ val cStringEmb = (toCString, fromCString)
+ val stringEmb = (toString, fromString)
end
end
Modified: mltonlib/trunk/com/ssh/extended-basis/unstable/mk-word-ext.fun
===================================================================
--- mltonlib/trunk/com/ssh/extended-basis/unstable/mk-word-ext.fun 2006-10-19 09:31:43 UTC (rev 4729)
+++ mltonlib/trunk/com/ssh/extended-basis/unstable/mk-word-ext.fun 2006-10-19 13:52:06 UTC (rev 4730)
@@ -13,14 +13,14 @@
open W
val toWord = Word.fromLarge o toLarge
val fromWord = fromLarge o Word.toLarge
- val int = (toInt, fromInt)
- val intX = (toIntX, fromInt)
- val large = (toLarge, fromLarge)
- val largeInt = (toLargeInt, fromLargeInt)
- val largeIntX = (toLargeIntX, fromLargeInt)
- val largeX = (toLargeX, fromLarge)
- val word = (toWord, fromWord)
- val string = (toString, fromString)
+ val intIso = (toInt, fromInt)
+ val intXIso = (toIntX, fromInt)
+ val largeIso = (toLarge, fromLarge)
+ val largeIntIso = (toLargeInt, fromLargeInt)
+ val largeIntXIso = (toLargeIntX, fromLargeInt)
+ val largeXIso = (toLargeX, fromLarge)
+ val wordIso = (toWord, fromWord)
+ val stringEmb = (toString, fromString)
fun isZero w = fromInt 0 = w
fun isEven w = isZero (andb (fromInt 1, w))
val isOdd = not o isEven
Modified: mltonlib/trunk/com/ssh/extended-basis/unstable/mono-array.sig
===================================================================
--- mltonlib/trunk/com/ssh/extended-basis/unstable/mono-array.sig 2006-10-19 09:31:43 UTC (rev 4729)
+++ mltonlib/trunk/com/ssh/extended-basis/unstable/mono-array.sig 2006-10-19 13:52:06 UTC (rev 4730)
@@ -11,6 +11,9 @@
signature MONO_ARRAY =
sig
include MONO_ARRAY
- val list : (array, elem list) iso
val toList : array -> elem list
+ val listIso : (array, elem list) iso
+ val toVector : array -> vector
+ val fromVector : vector -> array
+ val vectorIso : (array, vector) iso
end
Modified: mltonlib/trunk/com/ssh/extended-basis/unstable/mono-arrays-mlton.sml
===================================================================
--- mltonlib/trunk/com/ssh/extended-basis/unstable/mono-arrays-mlton.sml 2006-10-19 09:31:43 UTC (rev 4729)
+++ mltonlib/trunk/com/ssh/extended-basis/unstable/mono-arrays-mlton.sml 2006-10-19 13:52:06 UTC (rev 4730)
@@ -8,23 +8,57 @@
* Extended {MONO_ARRAY} modules for MLton.
*)
-structure BoolArray : MONO_ARRAY = MkMonoArrayExt (BoolArray)
+structure BoolArray : MONO_ARRAY =
+ MkMonoArrayExt (structure MonoArray = BoolArray
+ structure MonoVector = BoolVector)
-structure IntArray : MONO_ARRAY = MkMonoArrayExt (IntArray)
-structure LargeIntArray : MONO_ARRAY = MkMonoArrayExt (LargeIntArray)
-structure Int8Array : MONO_ARRAY = MkMonoArrayExt (Int8Array)
-structure Int16Array : MONO_ARRAY = MkMonoArrayExt (Int16Array)
-structure Int32Array : MONO_ARRAY = MkMonoArrayExt (Int32Array)
-structure Int64Array : MONO_ARRAY = MkMonoArrayExt (Int64Array)
+structure IntArray : MONO_ARRAY =
+ MkMonoArrayExt (structure MonoArray = IntArray
+ structure MonoVector = IntVector)
+structure LargeIntArray : MONO_ARRAY =
+ MkMonoArrayExt (structure MonoArray = LargeIntArray
+ structure MonoVector = LargeIntVector)
+structure Int8Array : MONO_ARRAY =
+ MkMonoArrayExt (structure MonoArray = Int8Array
+ structure MonoVector = Int8Vector)
+structure Int16Array : MONO_ARRAY =
+ MkMonoArrayExt (structure MonoArray = Int16Array
+ structure MonoVector = Int16Vector)
+structure Int32Array : MONO_ARRAY =
+ MkMonoArrayExt (structure MonoArray = Int32Array
+ structure MonoVector = Int32Vector)
+structure Int64Array : MONO_ARRAY =
+ MkMonoArrayExt (structure MonoArray = Int64Array
+ structure MonoVector = Int64Vector)
-structure RealArray : MONO_ARRAY = MkMonoArrayExt (RealArray)
-structure LargeRealArray : MONO_ARRAY = MkMonoArrayExt (LargeRealArray)
-structure Real32Array : MONO_ARRAY = MkMonoArrayExt (Real32Array)
-structure Real64Array : MONO_ARRAY = MkMonoArrayExt (Real64Array)
+structure RealArray : MONO_ARRAY =
+ MkMonoArrayExt (structure MonoArray = RealArray
+ structure MonoVector = RealVector)
+structure LargeRealArray : MONO_ARRAY =
+ MkMonoArrayExt (structure MonoArray = LargeRealArray
+ structure MonoVector = LargeRealVector)
+structure Real32Array : MONO_ARRAY =
+ MkMonoArrayExt (structure MonoArray = Real32Array
+ structure MonoVector = Real32Vector)
+structure Real64Array : MONO_ARRAY =
+ MkMonoArrayExt (structure MonoArray = Real64Array
+ structure MonoVector = Real64Vector)
-structure WordArray : MONO_ARRAY = MkMonoArrayExt (WordArray)
-structure LargeWordArray : MONO_ARRAY = MkMonoArrayExt (LargeWordArray)
-structure Word8Array : MONO_ARRAY = MkMonoArrayExt (Word8Array)
-structure Word16Array : MONO_ARRAY = MkMonoArrayExt (Word16Array)
-structure Word32Array : MONO_ARRAY = MkMonoArrayExt (Word32Array)
-structure Word64Array : MONO_ARRAY = MkMonoArrayExt (Word64Array)
+structure WordArray : MONO_ARRAY =
+ MkMonoArrayExt (structure MonoArray = WordArray
+ structure MonoVector = WordVector)
+structure LargeWordArray : MONO_ARRAY =
+ MkMonoArrayExt (structure MonoArray = LargeWordArray
+ structure MonoVector = LargeWordVector)
+structure Word8Array : MONO_ARRAY =
+ MkMonoArrayExt (structure MonoArray = Word8Array
+ structure MonoVector = Word8Vector)
+structure Word16Array : MONO_ARRAY =
+ MkMonoArrayExt (structure MonoArray = Word16Array
+ structure MonoVector = Word16Vector)
+structure Word32Array : MONO_ARRAY =
+ MkMonoArrayExt (structure MonoArray = Word32Array
+ structure MonoVector = Word32Vector)
+structure Word64Array : MONO_ARRAY =
+ MkMonoArrayExt (structure MonoArray = Word64Array
+ structure MonoVector = Word64Vector)
Modified: mltonlib/trunk/com/ssh/extended-basis/unstable/mono-vector.sig
===================================================================
--- mltonlib/trunk/com/ssh/extended-basis/unstable/mono-vector.sig 2006-10-19 09:31:43 UTC (rev 4729)
+++ mltonlib/trunk/com/ssh/extended-basis/unstable/mono-vector.sig 2006-10-19 13:52:06 UTC (rev 4730)
@@ -11,6 +11,6 @@
signature MONO_VECTOR =
sig
include MONO_VECTOR
- val list : (vector, elem list) iso
+ val listIso : (vector, elem list) iso
val toList : vector -> elem list
end
Modified: mltonlib/trunk/com/ssh/extended-basis/unstable/real.sig
===================================================================
--- mltonlib/trunk/com/ssh/extended-basis/unstable/real.sig 2006-10-19 09:31:43 UTC (rev 4729)
+++ mltonlib/trunk/com/ssh/extended-basis/unstable/real.sig 2006-10-19 13:52:06 UTC (rev 4730)
@@ -11,10 +11,10 @@
signature REAL =
sig
include REAL
- val decimal : (real, IEEEReal.decimal_approx) emb
- val int : (real, Int.int) iso
- val large : (real, LargeReal.real) iso
- val largeInt : (real, LargeInt.int) iso
- val manExp : (real, {man : real, exp : int}) iso
- val string : (real, string) emb
+ val decimalEmb : (real, IEEEReal.decimal_approx) emb
+ val intIso : (real, Int.int) iso
+ val largeIso : (real, LargeReal.real) iso
+ val largeIntIso : (real, LargeInt.int) iso
+ val manExpIso : (real, {man : real, exp : int}) iso
+ val stringEmb : (real, string) emb
end
Modified: mltonlib/trunk/com/ssh/extended-basis/unstable/string.sig
===================================================================
--- mltonlib/trunk/com/ssh/extended-basis/unstable/string.sig 2006-10-19 09:31:43 UTC (rev 4729)
+++ mltonlib/trunk/com/ssh/extended-basis/unstable/string.sig 2006-10-19 13:52:06 UTC (rev 4730)
@@ -11,9 +11,9 @@
signature STRING =
sig
include STRING
- val list : (string, char list) iso
- val cString : (string, string) emb
- val string : (string, string) emb
+ val listIso : (string, char list) iso
+ val cStringEmb : (string, string) emb
+ val stringEmb : (string, string) emb
type vector = string
type elem = char
Modified: mltonlib/trunk/com/ssh/extended-basis/unstable/vector.sml
===================================================================
--- mltonlib/trunk/com/ssh/extended-basis/unstable/vector.sml 2006-10-19 09:31:43 UTC (rev 4729)
+++ mltonlib/trunk/com/ssh/extended-basis/unstable/vector.sml 2006-10-19 13:52:06 UTC (rev 4730)
@@ -11,7 +11,7 @@
signature VECTOR =
sig
include VECTOR
- val list : ('a vector, 'a list) iso
+ val listIso : ('a vector, 'a list) iso
val toList : 'a vector -> 'a list
end
@@ -19,5 +19,5 @@
struct
open Vector
fun toList v = foldr op :: [] v
- val list = (toList, fromList)
+ val listIso = (toList, fromList)
end
Modified: mltonlib/trunk/com/ssh/extended-basis/unstable/word.sig
===================================================================
--- mltonlib/trunk/com/ssh/extended-basis/unstable/word.sig 2006-10-19 09:31:43 UTC (rev 4729)
+++ mltonlib/trunk/com/ssh/extended-basis/unstable/word.sig 2006-10-19 13:52:06 UTC (rev 4730)
@@ -13,14 +13,14 @@
include WORD
val toWord : word -> Word.word
val fromWord : Word.word -> word
- val int : (word, Int.int) iso
- val intX : (word, Int.int) iso
- val large : (word, LargeWord.word) iso
- val largeInt : (word, LargeInt.int) iso
- val largeIntX : (word, LargeInt.int) iso
- val largeX : (word, LargeWord.word) iso
- val word : (word, Word.word) iso
- val string : (word, string) emb
+ val intIso : (word, Int.int) iso
+ val intXIso : (word, Int.int) iso
+ val largeIso : (word, LargeWord.word) iso
+ val largeIntIso : (word, LargeInt.int) iso
+ val largeIntXIso : (word, LargeInt.int) iso
+ val largeXIso : (word, LargeWord.word) iso
+ val wordIso : (word, Word.word) iso
+ val stringEmb : (word, string) emb
val isZero : word -> bool
val isEven : word -> bool
val isOdd : word -> bool
More information about the MLton-commit
mailing list