Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 2 additions & 28 deletions src/ppx/ppx_lwt.ml
Original file line number Diff line number Diff line change
Expand Up @@ -446,32 +446,6 @@ let mapper =
"Lwt's finally should be used only with the syntax: \"(<expr>)[%%finally ...]\"."
))

| [%expr [%e? lhs] >> [%e? rhs]] as e ->
if !sequence then
let pat = if !strict_seq then [%pat? ()] else [%pat? _] in
let lhs, rhs = mapper.expr mapper lhs, mapper.expr mapper rhs in
let op = match e.Parsetree.pexp_desc with
| Parsetree.Pexp_apply (op, _) -> op
| _ -> assert false
in
if !debug then
Ast_helper.Exp.attr
([%expr
let module Reraise = struct external reraise : exn -> 'a = "%reraise" end in
Lwt.backtrace_bind
(fun exn -> try Reraise.reraise exn with exn -> exn)
[%e lhs]
(fun [%p pat] -> [%e rhs])
] [@metaloc lhs.pexp_loc])
(Ast_mapper.attribute_of_warning op.Parsetree.pexp_loc
"The operator >> is deprecated")
else
Ast_helper.Exp.attr
[%expr (Lwt.bind [%e lhs] (fun [%p pat] -> [%e rhs]))]
(Ast_mapper.attribute_of_warning op.Parsetree.pexp_loc
"The operator >> is deprecated")
else
default_mapper.expr mapper expr
| { pexp_desc = Pexp_apply (fn, args); pexp_attributes; pexp_loc } when !log ->
default_loc := pexp_loc;
lwt_log mapper fn args pexp_attributes pexp_loc
Expand Down Expand Up @@ -511,11 +485,11 @@ let args =

"-no-sequence",
Unit no_sequence_option,
" disable sequence operator (deprecated)";
" has no effect (deprecated)";

"-no-strict-sequence",
Unit no_strict_sequence_option,
" allow non-unit sequence operations (deprecated)";
" has no effect (deprecated)";
])

let () =
Expand Down
31 changes: 0 additions & 31 deletions src/ppx/ppx_lwt.mli
Original file line number Diff line number Diff line change
Expand Up @@ -191,37 +191,6 @@ $ ocamlfind ocamlc -package lwt.ppx \
-ppxopt lwt.ppx,-no-debug -linkpkg -o foo foo.ml
v}

{2 Sequence}

With OCaml 4.04.0 and on a convenient syntax is available for sequencing Lwt
operations using [;%lwt]. This allows free mixing of standard [;]
sequencing and [;%lwt] sequencing without extra parentheses:
{[
let i = ref 0 in
write stdout "Hello, ";%lwt
incr i;
write stdout "world!"
]}

It is also possible to sequence Lwt operations with the [>>] operator:
{[
write stdout "Hello, " >> write stdout "world!"
]}

By default, each operation must return [unit Lwt.t]. This constraint can be
lifted with the option [-no-strict-sequence]. The operator can be disabled
with the option [-no-sequence].

If you are mixing `>>` and `;`, you need to use parentheses or `begin`/`end`
to get the result you expect:

{[
write stdout "Hello, " >> (ignore (); write stdout "world!")
]}

Note that unlike [>>=], [>>] is not an OCaml value. it is a piece of syntax
added by the ppx rewriter - i.e., you cannot refer to [(>>)].

{2 Logging}

The logging syntax extension is enabled with [-log].
Expand Down
5 changes: 4 additions & 1 deletion test/packaging/jbuilder/ppx/user.ml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
let () =
let p = Lwt.return () >> Lwt.return () in
let p =
let%lwt () = Lwt.return () in
Lwt.return ()
in
ignore p
8 changes: 0 additions & 8 deletions test/packaging/jbuilder/ppx_ppxopt/Makefile

This file was deleted.

6 changes: 0 additions & 6 deletions test/packaging/jbuilder/ppx_ppxopt/jbuild

This file was deleted.

3 changes: 0 additions & 3 deletions test/packaging/jbuilder/ppx_ppxopt/user.ml

This file was deleted.

3 changes: 0 additions & 3 deletions test/packaging/ocamlfind/ppx/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ test : clean
ocamlfind opt -package lwt_ppx -c user.ml
ocamlfind opt -package lwt -linkpkg user.cmx
./a.out
# Expecting failure with "Unbound value >>":
! ocamlfind opt -package lwt_ppx \
-ppxopt lwt_ppx,-no-sequence -c user.ml

.PHONY : clean
clean :
Expand Down
5 changes: 4 additions & 1 deletion test/packaging/ocamlfind/ppx/user.ml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
let () =
let p = Lwt.return () >> Lwt.return () in
let p =
let%lwt () = Lwt.return () in
Lwt.return ()
in
ignore p
8 changes: 0 additions & 8 deletions test/ppx/main.ml
Original file line number Diff line number Diff line change
Expand Up @@ -155,14 +155,6 @@ let suite = suite "ppx" [
return !x
) ;

test "sequence"
(fun () ->
let lst = ref [] in
(lst := 2 :: !lst; Lwt.return_unit) >>
(lst := 1 :: !lst; Lwt.return_unit) >>
(Lwt.return (!lst = [1;2]))
) ;

test "structure let"
(fun () ->
let module M =
Expand Down