[MLton-commit] r6960
Vesa Karvonen
vesak at mlton.org
Mon Oct 20 00:27:48 PDT 2008
Restructuring examples.
----------------------------------------------------------------------
A mltonlib/trunk/org/mlton/vesak/rpc-lib/unstable/example/
A mltonlib/trunk/org/mlton/vesak/rpc-lib/unstable/example/assoc/
A mltonlib/trunk/org/mlton/vesak/rpc-lib/unstable/example/assoc/Build.bgb
A mltonlib/trunk/org/mlton/vesak/rpc-lib/unstable/example/assoc/Build.sh
A mltonlib/trunk/org/mlton/vesak/rpc-lib/unstable/example/assoc/app/
A mltonlib/trunk/org/mlton/vesak/rpc-lib/unstable/example/assoc/app/generic.mlb
A mltonlib/trunk/org/mlton/vesak/rpc-lib/unstable/example/assoc/app/generic.use
A mltonlib/trunk/org/mlton/vesak/rpc-lib/unstable/example/assoc/client.mlb
A mltonlib/trunk/org/mlton/vesak/rpc-lib/unstable/example/assoc/client.sml
A mltonlib/trunk/org/mlton/vesak/rpc-lib/unstable/example/assoc/client.use
A mltonlib/trunk/org/mlton/vesak/rpc-lib/unstable/example/assoc/common.sml
A mltonlib/trunk/org/mlton/vesak/rpc-lib/unstable/example/assoc/server.mlb
A mltonlib/trunk/org/mlton/vesak/rpc-lib/unstable/example/assoc/server.sml
A mltonlib/trunk/org/mlton/vesak/rpc-lib/unstable/example/assoc/server.use
----------------------------------------------------------------------
Property changes on: mltonlib/trunk/org/mlton/vesak/rpc-lib/unstable/example
___________________________________________________________________
Name: svn:mergeinfo
+
Property changes on: mltonlib/trunk/org/mlton/vesak/rpc-lib/unstable/example/assoc
___________________________________________________________________
Name: svn:ignore
+ generated
Added: mltonlib/trunk/org/mlton/vesak/rpc-lib/unstable/example/assoc/Build.bgb
===================================================================
--- mltonlib/trunk/org/mlton/vesak/rpc-lib/unstable/example/assoc/Build.bgb 2008-10-20 07:22:16 UTC (rev 6959)
+++ mltonlib/trunk/org/mlton/vesak/rpc-lib/unstable/example/assoc/Build.bgb 2008-10-20 07:27:36 UTC (rev 6960)
@@ -0,0 +1,8 @@
+;; Copyright (C) 2008 Vesa Karvonen
+;;
+;; This code is released under the MLton license, a BSD-style license.
+;; See the LICENSE file or http://mlton.org/License for details.
+
+(bg-build
+ :name "RPC-lib example"
+ :shell "nice -n5 ./Build.sh")
Added: mltonlib/trunk/org/mlton/vesak/rpc-lib/unstable/example/assoc/Build.sh
===================================================================
--- mltonlib/trunk/org/mlton/vesak/rpc-lib/unstable/example/assoc/Build.sh 2008-10-20 07:22:16 UTC (rev 6959)
+++ mltonlib/trunk/org/mlton/vesak/rpc-lib/unstable/example/assoc/Build.sh 2008-10-20 07:27:36 UTC (rev 6960)
@@ -0,0 +1,26 @@
+#!/bin/bash
+
+# Copyright (C) 2008 Vesa Karvonen
+#
+# This code is released under the MLton license, a BSD-style license.
+# See the LICENSE file or http://mlton.org/License for details.
+
+set -e
+set -x
+
+mkdir -p generated
+
+function Compile {
+ mlton -mlb-path-var "MLTON_LIB $(cd ../../../../../../.. && pwd)" \
+ -mlb-path-var "SML_COMPILER mlton" \
+ -mlb-path-var "APPLICATION $(pwd)/app" \
+ -prefer-abs-paths true \
+ -show-def-use "generated/$1.du" \
+ -output "generated/$1" \
+ "$1.mlb"
+ strip "generated/$1"
+ ls -l "generated/$1"
+}
+
+Compile server
+Compile client
Added: mltonlib/trunk/org/mlton/vesak/rpc-lib/unstable/example/assoc/app/generic.mlb
===================================================================
--- mltonlib/trunk/org/mlton/vesak/rpc-lib/unstable/example/assoc/app/generic.mlb 2008-10-20 07:22:16 UTC (rev 6959)
+++ mltonlib/trunk/org/mlton/vesak/rpc-lib/unstable/example/assoc/app/generic.mlb 2008-10-20 07:27:36 UTC (rev 6960)
@@ -0,0 +1,23 @@
+(* Copyright (C) 2008 Vesa Karvonen
+ *
+ * This code is released under the MLton license, a BSD-style license.
+ * See the LICENSE file or http://mlton.org/License for details.
+ *)
+
+local
+ $(MLTON_LIB)/com/ssh/extended-basis/unstable/basis.mlb
+ $(MLTON_LIB)/com/ssh/generic/unstable/lib.mlb
+in
+ $(MLTON_LIB)/com/ssh/generic/unstable/with/generic.sml
+ $(MLTON_LIB)/com/ssh/generic/unstable/with/type-info.sml
+ $(MLTON_LIB)/com/ssh/generic/unstable/with/type-hash.sml
+ $(MLTON_LIB)/com/ssh/generic/unstable/with/hash.sml
+ $(MLTON_LIB)/com/ssh/generic/unstable/with/pretty.sml
+ $(MLTON_LIB)/com/ssh/generic/unstable/with/eq.sml
+ $(MLTON_LIB)/com/ssh/generic/unstable/with/some.sml
+ $(MLTON_LIB)/com/ssh/generic/unstable/with/pickle.sml
+ $(MLTON_LIB)/com/ssh/generic/unstable/with/close-pretty-with-extra.sml
+ $(MLTON_LIB)/com/ssh/generic/unstable/with/reg-basis-exns.sml
+ $(MLTON_LIB)/com/ssh/generic/unstable/with/types.sml
+ $(MLTON_LIB)/com/ssh/generic/unstable/with/types-$(SML_COMPILER).sml
+end
Added: mltonlib/trunk/org/mlton/vesak/rpc-lib/unstable/example/assoc/app/generic.use
===================================================================
--- mltonlib/trunk/org/mlton/vesak/rpc-lib/unstable/example/assoc/app/generic.use 2008-10-20 07:22:16 UTC (rev 6959)
+++ mltonlib/trunk/org/mlton/vesak/rpc-lib/unstable/example/assoc/app/generic.use 2008-10-20 07:27:36 UTC (rev 6960)
@@ -0,0 +1,20 @@
+(* Copyright (C) 2008 Vesa Karvonen
+ *
+ * This code is released under the MLton license, a BSD-style license.
+ * See the LICENSE file or http://mlton.org/License for details.
+ *)
+
+lib ["${MLTON_LIB}/com/ssh/extended-basis/unstable/basis.use",
+ "${MLTON_LIB}/com/ssh/generic/unstable/lib.use",
+ "${MLTON_LIB}/com/ssh/generic/unstable/with/generic.sml",
+ "${MLTON_LIB}/com/ssh/generic/unstable/with/type-info.sml",
+ "${MLTON_LIB}/com/ssh/generic/unstable/with/type-hash.sml",
+ "${MLTON_LIB}/com/ssh/generic/unstable/with/hash.sml",
+ "${MLTON_LIB}/com/ssh/generic/unstable/with/pretty.sml",
+ "${MLTON_LIB}/com/ssh/generic/unstable/with/eq.sml",
+ "${MLTON_LIB}/com/ssh/generic/unstable/with/some.sml",
+ "${MLTON_LIB}/com/ssh/generic/unstable/with/pickle.sml",
+ "${MLTON_LIB}/com/ssh/generic/unstable/with/close-pretty-with-extra.sml",
+ "${MLTON_LIB}/com/ssh/generic/unstable/with/reg-basis-exns.sml",
+ "${MLTON_LIB}/com/ssh/generic/unstable/with/types.sml",
+ "${MLTON_LIB}/com/ssh/generic/unstable/with/types-${SML_COMPILER}.sml"] ;
Added: mltonlib/trunk/org/mlton/vesak/rpc-lib/unstable/example/assoc/client.mlb
===================================================================
--- mltonlib/trunk/org/mlton/vesak/rpc-lib/unstable/example/assoc/client.mlb 2008-10-20 07:22:16 UTC (rev 6959)
+++ mltonlib/trunk/org/mlton/vesak/rpc-lib/unstable/example/assoc/client.mlb 2008-10-20 07:27:36 UTC (rev 6960)
@@ -0,0 +1,22 @@
+(* Copyright (C) 2008 Vesa Karvonen
+ *
+ * This code is released under the MLton license, a BSD-style license.
+ * See the LICENSE file or http://mlton.org/License for details.
+ *)
+
+$(MLTON_LIB)/com/ssh/extended-basis/unstable/basis.mlb
+$(MLTON_LIB)/org/mlton/vesak/rpc-lib/unstable/lib-client.mlb
+
+$(APPLICATION)/generic.mlb
+
+ann
+ "forceUsed"
+ "sequenceNonUnit warn"
+ "warnUnused true"
+in
+ local
+ common.sml
+ client.sml
+ in
+ end
+end
Added: mltonlib/trunk/org/mlton/vesak/rpc-lib/unstable/example/assoc/client.sml
===================================================================
--- mltonlib/trunk/org/mlton/vesak/rpc-lib/unstable/example/assoc/client.sml 2008-10-20 07:22:16 UTC (rev 6959)
+++ mltonlib/trunk/org/mlton/vesak/rpc-lib/unstable/example/assoc/client.sml 2008-10-20 07:27:36 UTC (rev 6960)
@@ -0,0 +1,22 @@
+(* Copyright (C) 2008 Vesa Karvonen
+ *
+ * This code is released under the MLton license, a BSD-style license.
+ * See the LICENSE file or http://mlton.org/License for details.
+ *)
+
+val conn = Client.TCP.connect (U#tcpNoDelay true) $
+
+local
+ fun mk s = verbose "client: " s (Client.Reply.sync o Client.declare s conn)
+in
+ val {bind, bindings, find} =
+ mkLib {bind = mk, bindings = mk, find = mk}
+end
+
+val () =
+ (find "x" >| ignore
+ ; bind ("x", 1234)
+ ; find "x" >| ignore
+ ; bindings () >| ignore)
+
+val () = Client.Conn.close conn
Added: mltonlib/trunk/org/mlton/vesak/rpc-lib/unstable/example/assoc/client.use
===================================================================
--- mltonlib/trunk/org/mlton/vesak/rpc-lib/unstable/example/assoc/client.use 2008-10-20 07:22:16 UTC (rev 6959)
+++ mltonlib/trunk/org/mlton/vesak/rpc-lib/unstable/example/assoc/client.use 2008-10-20 07:27:36 UTC (rev 6960)
@@ -0,0 +1,11 @@
+(* Copyright (C) 2008 Vesa Karvonen
+ *
+ * This code is released under the MLton license, a BSD-style license.
+ * See the LICENSE file or http://mlton.org/License for details.
+ *)
+
+lib ["${MLTON_LIB}/com/ssh/extended-basis/unstable/basis.use",
+ "${MLTON_LIB}/org/mlton/vesak/rpc-lib/unstable/lib-client.use",
+ "${APPLICATION}/generic.use",
+ "common.sml",
+ "client.sml"] ;
Added: mltonlib/trunk/org/mlton/vesak/rpc-lib/unstable/example/assoc/common.sml
===================================================================
--- mltonlib/trunk/org/mlton/vesak/rpc-lib/unstable/example/assoc/common.sml 2008-10-20 07:22:16 UTC (rev 6959)
+++ mltonlib/trunk/org/mlton/vesak/rpc-lib/unstable/example/assoc/common.sml 2008-10-20 07:27:36 UTC (rev 6960)
@@ -0,0 +1,21 @@
+(* Copyright (C) 2008 Vesa Karvonen
+ *
+ * This code is released under the MLton license, a BSD-style license.
+ * See the LICENSE file or http://mlton.org/License for details.
+ *)
+
+fun mkLib {bind, bindings, find} =
+ {bind = bind (Pair.t (String.t, Int.t), Unit.t, "bind"),
+ bindings =
+ bindings (Unit.t, List.t (Pair.t (String.t, Int.t)), "bindings"),
+ find = find (String.t, Option.t Int.t, "find")}
+
+fun verbose h (d, c, n) f x =
+ try (fn () => f x,
+ fn y =>
+ (printlns [h, n, " ", Generic.show d x, " => ", Generic.show c y]
+ ; y),
+ fn e =>
+ (printlns
+ [h, n, " ", Generic.show d x, " raised ", Generic.show Exn.t e]
+ ; raise e))
Added: mltonlib/trunk/org/mlton/vesak/rpc-lib/unstable/example/assoc/server.mlb
===================================================================
--- mltonlib/trunk/org/mlton/vesak/rpc-lib/unstable/example/assoc/server.mlb 2008-10-20 07:22:16 UTC (rev 6959)
+++ mltonlib/trunk/org/mlton/vesak/rpc-lib/unstable/example/assoc/server.mlb 2008-10-20 07:27:36 UTC (rev 6960)
@@ -0,0 +1,22 @@
+(* Copyright (C) 2008 Vesa Karvonen
+ *
+ * This code is released under the MLton license, a BSD-style license.
+ * See the LICENSE file or http://mlton.org/License for details.
+ *)
+
+$(MLTON_LIB)/com/ssh/extended-basis/unstable/basis.mlb
+$(MLTON_LIB)/org/mlton/vesak/rpc-lib/unstable/lib-server.mlb
+
+$(APPLICATION)/generic.mlb
+
+ann
+ "forceUsed"
+ "sequenceNonUnit warn"
+ "warnUnused true"
+in
+ local
+ common.sml
+ server.sml
+ in
+ end
+end
Added: mltonlib/trunk/org/mlton/vesak/rpc-lib/unstable/example/assoc/server.sml
===================================================================
--- mltonlib/trunk/org/mlton/vesak/rpc-lib/unstable/example/assoc/server.sml 2008-10-20 07:22:16 UTC (rev 6959)
+++ mltonlib/trunk/org/mlton/vesak/rpc-lib/unstable/example/assoc/server.sml 2008-10-20 07:27:36 UTC (rev 6960)
@@ -0,0 +1,23 @@
+(* Copyright (C) 2008 Vesa Karvonen
+ *
+ * This code is released under the MLton license, a BSD-style license.
+ * See the LICENSE file or http://mlton.org/License for details.
+ *)
+
+local
+ val assoc : (String.t * Int.t) List.t Ref.t = ref []
+in
+ fun bind (k, v) = assoc := (k, v) :: List.filter (notEq k o #1) (!assoc)
+ fun bindings () = !assoc
+ fun find k = Option.map #2 (List.find (eq k o #1) (!assoc))
+end
+
+val () = let
+ open Server
+ val procMap = ProcMap.new ()
+ fun ` f s = ProcMap.add procMap s (verbose "server: " s f)
+in
+ mkLib {bind = `bind, bindings = `bindings, find = `find} >| ignore
+ ; TCP.start procMap (U#numAccepts (SOME 1)) (U#tcpNoDelay true) $
+ ; run ()
+end
Added: mltonlib/trunk/org/mlton/vesak/rpc-lib/unstable/example/assoc/server.use
===================================================================
--- mltonlib/trunk/org/mlton/vesak/rpc-lib/unstable/example/assoc/server.use 2008-10-20 07:22:16 UTC (rev 6959)
+++ mltonlib/trunk/org/mlton/vesak/rpc-lib/unstable/example/assoc/server.use 2008-10-20 07:27:36 UTC (rev 6960)
@@ -0,0 +1,11 @@
+(* Copyright (C) 2008 Vesa Karvonen
+ *
+ * This code is released under the MLton license, a BSD-style license.
+ * See the LICENSE file or http://mlton.org/License for details.
+ *)
+
+lib ["${MLTON_LIB}/com/ssh/extended-basis/unstable/basis.use",
+ "${MLTON_LIB}/org/mlton/vesak/rpc-lib/unstable/lib-server.use",
+ "${APPLICATION}/generic.use",
+ "common.sml",
+ "server.sml"] ;
More information about the MLton-commit
mailing list