From 1f463c1e9c8f302173ca8ead39c5e95be02a91e2 Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Sun, 4 Oct 2015 21:11:12 +0200 Subject: [PATCH] expose blocking decoder in `CCSexpM` --- src/sexp/CCSexpM.ml | 6 ++++-- src/sexp/CCSexpM.mli | 8 ++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/sexp/CCSexpM.ml b/src/sexp/CCSexpM.ml index 2dd9e49c..1fa12bef 100644 --- a/src/sexp/CCSexpM.ml +++ b/src/sexp/CCSexpM.ml @@ -309,11 +309,13 @@ module MakeDecode(M : MONAD) = struct expr_or_end (fun _ x -> M.return (`Ok x)) t end -module D = MakeDecode(struct +module ID_MONAD = struct type 'a t = 'a let return x = x let (>>=) x f = f x -end) +end + +module D = MakeDecode(ID_MONAD) let parse_string s : t or_error = let n = String.length s in diff --git a/src/sexp/CCSexpM.mli b/src/sexp/CCSexpM.mli index 5507fc20..704d0bc4 100644 --- a/src/sexp/CCSexpM.mli +++ b/src/sexp/CCSexpM.mli @@ -86,6 +86,14 @@ module MakeDecode(M : MONAD) : sig long enough or isn't a proper S-expression *) end +module ID_MONAD : MONAD +(** The monad that just uses blocking calls as bind + @since NEXT_RELEASE *) + +module D : module type of MakeDecode(ID_MONAD) +(** Decoder that just blocks when input is not available + @since NEXT_RELEASE *) + val parse_string : string -> t or_error (** Parse a string *)