[MLton-commit] r5378

Vesa Karvonen vesak at mlton.org
Thu Mar 1 13:56:21 PST 2007


Added Void.
----------------------------------------------------------------------

U   mltonlib/trunk/com/ssh/extended-basis/unstable/LICENSE
U   mltonlib/trunk/com/ssh/extended-basis/unstable/detail/bootstrap.sml
U   mltonlib/trunk/com/ssh/extended-basis/unstable/detail/smlnj/sigs.cm
U   mltonlib/trunk/com/ssh/extended-basis/unstable/extensions.mlb
U   mltonlib/trunk/com/ssh/extended-basis/unstable/extensions.use
U   mltonlib/trunk/com/ssh/extended-basis/unstable/public/export/common.sml
A   mltonlib/trunk/com/ssh/extended-basis/unstable/public/void.sig

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

Modified: mltonlib/trunk/com/ssh/extended-basis/unstable/LICENSE
===================================================================
--- mltonlib/trunk/com/ssh/extended-basis/unstable/LICENSE	2007-03-01 17:26:26 UTC (rev 5377)
+++ mltonlib/trunk/com/ssh/extended-basis/unstable/LICENSE	2007-03-01 21:56:20 UTC (rev 5378)
@@ -1,6 +1,6 @@
 COPYRIGHT NOTICE, LICENSE AND DISCLAIMER.
 
-Copyright (C) 2006 SSH Communications Security, Helsinki, Finland
+Copyright (C) 2006-2007 SSH Communications Security, Helsinki, Finland
 
 Permission to use, copy, modify, and distribute this software and its
 documentation for any purpose and without fee is hereby granted,

Modified: mltonlib/trunk/com/ssh/extended-basis/unstable/detail/bootstrap.sml
===================================================================
--- mltonlib/trunk/com/ssh/extended-basis/unstable/detail/bootstrap.sml	2007-03-01 17:26:26 UTC (rev 5377)
+++ mltonlib/trunk/com/ssh/extended-basis/unstable/detail/bootstrap.sml	2007-03-01 21:56:20 UTC (rev 5378)
@@ -6,6 +6,7 @@
 
 (* Minimal modules for bootstrapping. *)
 
+structure Void = struct abstype t = T with fun void T = void T end end
 structure Exn = struct type t = exn end
 structure Fn = struct type ('a, 'b) t = 'a -> 'b end
 structure Unit = struct type t = unit end

Modified: mltonlib/trunk/com/ssh/extended-basis/unstable/detail/smlnj/sigs.cm
===================================================================
--- mltonlib/trunk/com/ssh/extended-basis/unstable/detail/smlnj/sigs.cm	2007-03-01 17:26:26 UTC (rev 5377)
+++ mltonlib/trunk/com/ssh/extended-basis/unstable/detail/smlnj/sigs.cm	2007-03-01 21:56:20 UTC (rev 5378)
@@ -61,6 +61,7 @@
    ../../public/text/string.sig
    ../../public/text/substring.sig
    ../../public/text/text.sig
+   ../../public/void.sig
    ../../public/with.sig
    ../../public/writer.sig
    funs.cm

Modified: mltonlib/trunk/com/ssh/extended-basis/unstable/extensions.mlb
===================================================================
--- mltonlib/trunk/com/ssh/extended-basis/unstable/extensions.mlb	2007-03-01 17:26:26 UTC (rev 5377)
+++ mltonlib/trunk/com/ssh/extended-basis/unstable/extensions.mlb	2007-03-01 21:56:20 UTC (rev 5378)
@@ -48,6 +48,7 @@
          (* Compiler specific extensions (if any). *)
          basis Ext = bas detail/$(SML_COMPILER)/extensions.mlb end
 
+         basis Void = bas public/void.sig end
          basis Fn = bas public/fn/fn.sig detail/fn.sml end
          basis Unit = bas public/data/unit.sig end
          basis Sq = bas public/data/sq.sig detail/sq.sml end
@@ -243,6 +244,7 @@
          open Scalars Seqs ShiftOp Sq Sum
          open TextIO Thunk Tie
          open Unit Univ UnOp UnPr
+         open Void
          open With Writer
       in
          public/export/$(SML_COMPILER).sml

Modified: mltonlib/trunk/com/ssh/extended-basis/unstable/extensions.use
===================================================================
--- mltonlib/trunk/com/ssh/extended-basis/unstable/extensions.use	2007-03-01 17:26:26 UTC (rev 5377)
+++ mltonlib/trunk/com/ssh/extended-basis/unstable/extensions.use	2007-03-01 21:56:20 UTC (rev 5378)
@@ -22,6 +22,7 @@
         "public/concept/signed.sig",
         "public/concept/stringable.sig",
         "detail/"^compiler^"/extensions.use",
+        "public/void.sig",
         "public/fn/fn.sig", "detail/fn.sml",
         "public/data/unit.sig",
         "public/data/sq.sig", "detail/sq.sml",

Modified: mltonlib/trunk/com/ssh/extended-basis/unstable/public/export/common.sml
===================================================================
--- mltonlib/trunk/com/ssh/extended-basis/unstable/public/export/common.sml	2007-03-01 17:26:26 UTC (rev 5377)
+++ mltonlib/trunk/com/ssh/extended-basis/unstable/public/export/common.sml	2007-03-01 21:56:20 UTC (rev 5378)
@@ -76,6 +76,7 @@
 signature UN_PR = UN_PR
 signature VECTOR = VECTOR
 signature VECTOR_SLICE = VECTOR_SLICE
+signature VOID = VOID
 signature WITH = WITH
 signature WORD = WORD
 signature WRITER = WRITER
@@ -135,6 +136,7 @@
 structure UnOp : UN_OP = UnOp
 structure Unit : UNIT = Unit
 structure VectorSlice : VECTOR_SLICE = VectorSlice
+structure Void : VOID = Void
 structure Word : WORD = Word
 structure Word8 : WORD = Word8
 structure Word8Array : MONO_ARRAY = Word8Array

Added: mltonlib/trunk/com/ssh/extended-basis/unstable/public/void.sig
===================================================================
--- mltonlib/trunk/com/ssh/extended-basis/unstable/public/void.sig	2007-03-01 17:26:26 UTC (rev 5377)
+++ mltonlib/trunk/com/ssh/extended-basis/unstable/public/void.sig	2007-03-01 21:56:20 UTC (rev 5378)
@@ -0,0 +1,52 @@
+(* Copyright (C) 2007 SSH Communications Security, Helsinki, Finland
+ *
+ * This code is released under the MLton license, a BSD-style license.
+ * See the LICENSE file or http://mlton.org/License for details.
+ *)
+
+(**
+ * Signature for the {Void} module.
+ *
+ * The idea of the {Void} module is that there is no way to create values
+ * of the {Void.t} type.  This means that a function whose range is
+ * {Void.t} can not return normally.  Such a function can only either
+ * raise an exception or call some other function that never returns.  On
+ * the other hand, a function whose domain is {Void.t} can never be
+ * called.
+ *
+ * Specifying {Void.t} as the range of a function that never returns may
+ * perhaps communicate the semantics of the function most directly:
+ *
+ *> val neverReturns : d -> Void.t
+ *
+ * It may also help to work around the value restriction in some cases.
+ * However, it is usually better to use a type variable as the range of
+ * function that never returns:
+ *
+ *> val neverReturns : d -> 'a
+ *
+ * In SML, a function whose range is a type variable that does not occur
+ * in the domain of the function can never return normally.  The benefit
+ * of using such a specification is that the function can be called
+ * conveniently from a context of any type.
+ *
+ * There is another more interesting use for {Void.t}.  Consider the
+ * following specification:
+ *
+ *> val mystery : (d -> Void.t) -> r
+ *
+ * The specification ensures that the mystery function can only be called
+ * with a function that never returns normally.  This can sometimes be a
+ * useful property to ensure.
+ *)
+signature VOID = sig
+   type t
+   (** A type that has no values. *)
+
+   val void : t -> 'a
+   (**
+    * This function can never be called, because there is no way to create
+    * values of type {t}.  However, you can use {void} to call a function
+    * whose range is of type {t} from a context of any type.
+    *)
+end


Property changes on: mltonlib/trunk/com/ssh/extended-basis/unstable/public/void.sig
___________________________________________________________________
Name: svn:eol-style
   + native




More information about the MLton-commit mailing list