MR requests

This commit is contained in:
Lesenechal Remi 2019-12-12 11:00:04 +01:00
parent df0dfb029b
commit c62f147a01
2 changed files with 5 additions and 10 deletions

View File

@ -5,9 +5,11 @@ let compile (program : Ast_simplified.program) : (Ast_typed.program * Typer.Solv
let () = Typer.Solver.discard_state state in let () = Typer.Solver.discard_state state in
ok @@ (prog_typed, state) ok @@ (prog_typed, state)
(* let apply (program : Ast_simplified.program) (entry_point : string) (param : Ast_simplified.expression) : Ast_simplified.expression result = *) let compile_expression ?(env = Ast_typed.Environment.full_empty) ~(state : Typer.Solver.state) (ae : Ast_simplified.expression)
: (Ast_typed.value * Typer.Solver.state) result =
Typer.type_expression env state ae
let apply (entry_point : string) (param : Ast_simplified.expression) : Ast_simplified.expression result = let apply (entry_point : string) (param : Ast_simplified.expression) : Ast_simplified.expression result =
(* let%bind (exp,_) = Ast_simplified.Misc.get_entry program entry_point in *)
let name = Var.of_name entry_point in let name = Var.of_name entry_point in
let entry_point_var : Ast_simplified.expression = let entry_point_var : Ast_simplified.expression =
{ expression = Ast_simplified.E_variable name ; { expression = Ast_simplified.E_variable name ;
@ -16,6 +18,3 @@ let apply (entry_point : string) (param : Ast_simplified.expression) : Ast_simpl
{ expression = Ast_simplified.E_application (entry_point_var, param) ; { expression = Ast_simplified.E_application (entry_point_var, param) ;
location = Virtual "generated application" } in location = Virtual "generated application" } in
ok applied ok applied
let compile_expression ?(env = Ast_typed.Environment.full_empty) ~(state : Typer.Solver.state) (ae : Ast_simplified.expression) : (Ast_typed.value * Typer.Solver.state) result =
Typer.type_expression env state ae

View File

@ -157,13 +157,9 @@ let aggregate_entry (lst : program) (form : form_t) : expression result =
match (entry_expression.content) with match (entry_expression.content) with
| (E_closure l) -> ( | (E_closure l) -> (
let l' = { l with body = wrapper l.body } in let l' = { l with body = wrapper l.body } in
let%bind t' =
let%bind (input_ty , output_ty) = get_t_function entry_expression.type_value in
ok (t_function input_ty output_ty)
in
let e' = { let e' = {
content = E_closure l' ; content = E_closure l' ;
type_value = t' ; type_value = entry_expression.type_value ;
} in } in
ok e' ok e'
) )