[MLton-commit] r5465

Vesa Karvonen vesak at mlton.org
Sun Mar 25 10:01:58 PST 2007


Added String.toBytes, String.fromBytes, and String.isoBytes.
----------------------------------------------------------------------

U   mltonlib/trunk/com/ssh/extended-basis/unstable/detail/ml/common/mono-seqs.sml
U   mltonlib/trunk/com/ssh/extended-basis/unstable/detail/text/mk-text-ext.fun
U   mltonlib/trunk/com/ssh/extended-basis/unstable/public/text/string.sig

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

Modified: mltonlib/trunk/com/ssh/extended-basis/unstable/detail/ml/common/mono-seqs.sml
===================================================================
--- mltonlib/trunk/com/ssh/extended-basis/unstable/detail/ml/common/mono-seqs.sml	2007-03-23 15:50:27 UTC (rev 5464)
+++ mltonlib/trunk/com/ssh/extended-basis/unstable/detail/ml/common/mono-seqs.sml	2007-03-25 18:01:57 UTC (rev 5465)
@@ -15,7 +15,7 @@
 structure Word8ArraySlice : MONO_ARRAY_SLICE =
    MkMonoArraySliceExt (structure MonoArraySlice = BasisWord8ArraySlice)
 
-structure Text : TEXT = MkTextExt (BasisText)
+structure Text : TEXT = MkTextExt (structure Text = BasisText open BasisByte)
 structure Char : CHAR = Text.Char
 structure CharArray : MONO_ARRAY = Text.CharArray
 structure CharArraySlice : MONO_ARRAY_SLICE = Text.CharArraySlice

Modified: mltonlib/trunk/com/ssh/extended-basis/unstable/detail/text/mk-text-ext.fun
===================================================================
--- mltonlib/trunk/com/ssh/extended-basis/unstable/detail/text/mk-text-ext.fun	2007-03-23 15:50:27 UTC (rev 5464)
+++ mltonlib/trunk/com/ssh/extended-basis/unstable/detail/text/mk-text-ext.fun	2007-03-25 18:01:57 UTC (rev 5465)
@@ -4,8 +4,14 @@
  * See the LICENSE file or http://mlton.org/License for details.
  *)
 
-functor MkTextExt (T : BASIS_TEXT) : TEXT = struct
-   open T
+functor MkTextExt (structure Text : BASIS_TEXT
+                   val stringToBytes :
+                       Text.String.string -> BasisWord8Vector.vector
+                   val bytesToString :
+                       BasisWord8Vector.vector -> Text.String.string)
+        : TEXT =
+struct
+   open Text
 
    structure Char : CHAR = struct
       structure Core = struct
@@ -61,6 +67,9 @@
          type ordered = t
          type scannable = t
          type stringable = t
+         val toBytes = stringToBytes
+         val fromBytes = bytesToString
+         val isoBytes = (toBytes, fromBytes)
          val toUpper = map Char.toUpper
          val toLower = map Char.toLower
          val embCString = (toCString, fromCString)

Modified: mltonlib/trunk/com/ssh/extended-basis/unstable/public/text/string.sig
===================================================================
--- mltonlib/trunk/com/ssh/extended-basis/unstable/public/text/string.sig	2007-03-23 15:50:27 UTC (rev 5464)
+++ mltonlib/trunk/com/ssh/extended-basis/unstable/public/text/string.sig	2007-03-25 18:01:57 UTC (rev 5465)
@@ -42,8 +42,22 @@
 
    val collate : char Cmp.t -> t Cmp.t
 
+   (** == Bytes == *)
+
+   val toBytes : t -> Word8Vector.t
+   (** Converts given string to a byte vector. *)
+
+   val fromBytes : Word8Vector.t -> t
+   (** Converts given byte vector to a string. *)
+
    (** == Isomorphisms == *)
 
+   val isoBytes : (t, Word8Vector.t) Iso.t
+   (**
+    * An isomorphism between strings and byte vectors.  It is always
+    * equivalent to {(toBytes, fromBytes)}.
+    *)
+
    val isoList : (t, char List.t) Iso.t
    (**
     * An isomorphism between strings and lists.  It is always equivalent




More information about the MLton-commit mailing list