diff --git a/_oasis b/_oasis index b7c9bd46..e82be260 100644 --- a/_oasis +++ b/_oasis @@ -55,7 +55,8 @@ Library "containers_thread" Library "containers_lwt" Path: . - Modules: Behavior + Modules: Behavior, Lwt_automaton + Pack: true FindlibName: lwt FindlibParent: containers Build$: flag(lwt) diff --git a/_tags b/_tags index 6ef0b93d..90173891 100644 --- a/_tags +++ b/_tags @@ -1,5 +1,5 @@ # OASIS_START -# DO NOT EDIT (digest: 1f5b1920aa5191df724ab0786999e476) +# DO NOT EDIT (digest: cb8d0069d6571765cb2126aec9384e1e) # Ignore VCS directories, you can use the same kind of rule outside # OASIS_START/STOP if you want to exclude directories that contains # useless stuff for the build process @@ -58,6 +58,8 @@ <*.ml{,i}>: package(threads) # Library containers_lwt "containers_lwt.cmxs": use_containers_lwt +"behavior.cmx": for-pack(Containers_lwt) +"lwt_automaton.cmx": for-pack(Containers_lwt) <*.ml{,i}>: use_containers <*.ml{,i}>: package(lwt) <*.ml{,i}>: package(unix) diff --git a/containers.odocl b/containers.odocl index fc95bd97..edefeb3e 100644 --- a/containers.odocl +++ b/containers.odocl @@ -1,5 +1,5 @@ # OASIS_START -# DO NOT EDIT (digest: 1374a4df6a056c922bd254bb51737f89) +# DO NOT EDIT (digest: 509efa2d48f1db17047d029d9c883d07) Cache Deque Gen @@ -39,4 +39,5 @@ TTree HGraph Automaton Behavior +Lwt_automaton # OASIS_STOP diff --git a/containers_lwt.mllib b/containers_lwt.mllib index fee92cec..2cafc3b9 100644 --- a/containers_lwt.mllib +++ b/containers_lwt.mllib @@ -1,4 +1,4 @@ # OASIS_START -# DO NOT EDIT (digest: b39a035a995fc6597c8eb942210d1527) -Behavior +# DO NOT EDIT (digest: bc144ef7b5b54947fab9662a822f9179) +Containers_lwt # OASIS_STOP diff --git a/containers_lwt.mlpack b/containers_lwt.mlpack new file mode 100644 index 00000000..29a67122 --- /dev/null +++ b/containers_lwt.mlpack @@ -0,0 +1,5 @@ +# OASIS_START +# DO NOT EDIT (digest: 0baec9dfd3857e8cff12e40cdf9ce7db) +Behavior +Lwt_automaton +# OASIS_STOP diff --git a/lwt_automaton.ml b/lwt_automaton.ml new file mode 100644 index 00000000..8d459ae6 --- /dev/null +++ b/lwt_automaton.ml @@ -0,0 +1,44 @@ + +(* +copyright (c) 2013, simon cruanes +all rights reserved. + +redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. redistributions in binary +form must reproduce the above copyright notice, this list of conditions and the +following disclaimer in the documentation and/or other materials provided with +the distribution. + +this software is provided by the copyright holders and contributors "as is" and +any express or implied warranties, including, but not limited to, the implied +warranties of merchantability and fitness for a particular purpose are +disclaimed. in no event shall the copyright holder or contributors be liable +for any direct, indirect, incidental, special, exemplary, or consequential +damages (including, but not limited to, procurement of substitute goods or +services; loss of use, data, or profits; or business interruption) however +caused and on any theory of liability, whether in contract, strict liability, +or tort (including negligence or otherwise) arising in any way out of the use +of this software, even if advised of the possibility of such damage. +*) + +(** {1 interface lwt-automaton} *) + +module I = struct + let send f i = + Lwt.on_success f (fun x -> Automaton.I.send x i) + + let iter_stream str i = + Lwt_stream.iter (fun x -> Automaton.I.send x i) str +end + +module O = struct + let next o = + let fut, send = Lwt.wait () in + Automaton.O.once o (Lwt.wakeup send); + fut +end + +let next_transition a = O.next (Automaton.Instance.transitions a) diff --git a/lwt_automaton.mli b/lwt_automaton.mli new file mode 100644 index 00000000..166f9463 --- /dev/null +++ b/lwt_automaton.mli @@ -0,0 +1,45 @@ + +(* +copyright (c) 2013, simon cruanes +all rights reserved. + +redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. redistributions in binary +form must reproduce the above copyright notice, this list of conditions and the +following disclaimer in the documentation and/or other materials provided with +the distribution. + +this software is provided by the copyright holders and contributors "as is" and +any express or implied warranties, including, but not limited to, the implied +warranties of merchantability and fitness for a particular purpose are +disclaimed. in no event shall the copyright holder or contributors be liable +for any direct, indirect, incidental, special, exemplary, or consequential +damages (including, but not limited to, procurement of substitute goods or +services; loss of use, data, or profits; or business interruption) however +caused and on any theory of liability, whether in contract, strict liability, +or tort (including negligence or otherwise) arising in any way out of the use +of this software, even if advised of the possibility of such damage. +*) + +(** {1 interface lwt-automaton} *) + +module I : sig + val send : 'a Lwt.t -> 'a Automaton.I.t -> unit + (** Feed the content of the Lwt value into the automaton input, as soon as + available *) + + val iter_stream : 'a Lwt_stream.t -> 'a Automaton.I.t -> unit Lwt.t + (** Iterate on the given stream, sending its elements to the automaton *) +end + +module O : sig + val next : 'a Automaton.O.t -> 'a Lwt.t + (** Wait for the next output *) +end + +val next_transition : + ('s,'i,'o) Automaton.Instance.t -> + ('s * 'i * 's * 'o list) Lwt.t diff --git a/setup.ml b/setup.ml index 2612f443..979607d8 100644 --- a/setup.ml +++ b/setup.ml @@ -1,7 +1,7 @@ (* setup.ml generated for the first time by OASIS v0.3.0 *) (* OASIS_START *) -(* DO NOT EDIT (digest: cee801fe92de05606feedd67587200c0) *) +(* DO NOT EDIT (digest: 7dab10989ebb7fbf9c63ffe468939fec) *) (* Regenerated by OASIS v0.4.1 Visit http://oasis.forge.ocamlcore.org for more information and @@ -6976,8 +6976,8 @@ let setup_t = bs_nativeopt = [(OASISExpr.EBool true, [])] }, { - lib_modules = ["Behavior"]; - lib_pack = false; + lib_modules = ["Behavior"; "Lwt_automaton"]; + lib_pack = true; lib_internal_modules = []; lib_findlib_parent = Some "containers"; lib_findlib_name = Some "lwt"; @@ -7216,8 +7216,7 @@ let setup_t = }; oasis_fn = Some "_oasis"; oasis_version = "0.4.1"; - oasis_digest = - Some "\184\233\242\020\229\248\226Y\185\173\235\251\207\183\236\221"; + oasis_digest = Some "Vjm\254\b\1605[\023\195\024\190\191}\232i"; oasis_exec = None; oasis_setup_args = []; setup_update = false @@ -7225,6 +7224,6 @@ let setup_t = let setup () = BaseSetup.setup setup_t;; -# 7229 "setup.ml" +# 7228 "setup.ml" (* OASIS_STOP *) let () = setup ();;