Skip to content

Commit

Permalink
Merge pull request #1 from aantron/master
Browse files Browse the repository at this point in the history
Support for nested let-binds.
  • Loading branch information
zepalmer committed Aug 23, 2015
2 parents 216b12d + c476b74 commit 0811022
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/ocaml_monadic.ml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ let ocaml_monadic_mapper argv =
; pexp_desc =
Pexp_apply(
bind_ident,
[ (no_label, bind_expr)
[ (no_label, mapper.expr mapper bind_expr)
; (no_label, cont_function)
]
)
Expand Down
17 changes: 17 additions & 0 deletions src_test/test.ml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@ let nondeterminism_test =
return (x+y)
;;

let nested_bind_test =
let open NondeterminismMonad in
let%bind x =
let%bind y = [1;2;3] in
return (y+1)
in
return (x+1)
;;

let halt_with s = print_endline s; exit 1;;

let () =
Expand All @@ -30,6 +39,14 @@ let () =
("Unexpected value from nondeterminism test: " ^
string_of_list string_of_int nondeterminism_test)
end;
begin
match nested_bind_test with
| [3;4;5] -> ()
| _ ->
halt_with
("Unexpected value from nested_bind test: " ^
string_of_list string_of_int nested_bind_test)
end;
print_endline "All tests passed."
;;

0 comments on commit 0811022

Please sign in to comment.