Jonathan Graveline pushed to branch graveline at Stefan / Typer
Commits: 9e9a8e89 by Jonathan Graveline at 2018-06-27T17:57:09Z Correction of macro "do", dflt-sym need a symbol and not just "_"
- - - - -
3 changed files:
- btl/pervasive.typer - samples/do.typer - tests/macro_do_test.ml
Changes:
===================================== btl/pervasive.typer ===================================== --- a/btl/pervasive.typer +++ b/btl/pervasive.typer @@ -416,13 +416,31 @@ test3 = test4; %%%% %%%% Macro : do %%%% +%%%% This file may not be up to date with version +%%%% in pervasive.typer +%%%% + +%% +%% Here's an example : +%% +%% fun = do { +%% str <- return "\n\tHello world!\n\n"; +%% print str; +%% }; +%% +%% str is bind by macro, +%% +%% fun is a command, +%% +%% do may contain do because it returns a command. +%%
assign = Sexp_symbol "<-";
get-sym : Sexp -> Sexp; get-sym sexp = let
- dflt-sym = (lambda _ -> Sexp_symbol "(_ : IO Unit)"); + dflt-sym = (lambda _ -> (Sexp_symbol " %not used% "));
in Sexp_dispatch sexp
===================================== samples/do.typer ===================================== --- a/samples/do.typer +++ b/samples/do.typer @@ -25,7 +25,7 @@ assign = Sexp_symbol "<-"; get-sym : Sexp -> Sexp; get-sym sexp = let
- dflt-sym = (lambda _ -> Sexp_symbol "(_ : IO Unit)"); + dflt-sym = (lambda _ -> (Sexp_symbol " %not used% "));
in Sexp_dispatch sexp
===================================== tests/macro_do_test.ml ===================================== --- a/tests/macro_do_test.ml +++ b/tests/macro_do_test.ml @@ -114,5 +114,36 @@ let _ = (add_test "DO MACROS" "do inside do" (fun () -> | _ -> failure ()) )
+(* declaring the type before assignement *) +(* this is an unexpected functionality that may be usefull *) +let _ = (add_test "DO MACROS" "assignement with type declaration" (fun () -> + let dcode = " + return = IO_return; + + nop = (lambda _ -> return ()); + + action = do + { + (t : Bool) <- return true; + + (f : Bool) <- return false; + + return (if_then_else_ f 333 + (if_then_else_ t 777 333)); + };" in + + let rctx, ectx = Elab.eval_decl_str dcode ectx rctx in + + let ecode = "action;" in + + let ret = Elab.eval_expr_str ecode ectx rctx in + + match ret with + | [Vcommand cmd] -> ( match (cmd ()) with + | Vint 777 -> success () + | _ -> failure () ) + | _ -> failure ()) +) + (* run all tests *) let _ = run_all ()
View it on GitLab: https://gitlab.com/monnier/typer/commit/9e9a8e89166c6270e77be19d6947b50c73bc...
Afficher les réponses par date