diff options
| author | Maxime Dénès | 2017-10-06 12:33:17 +0200 |
|---|---|---|
| committer | Maxime Dénès | 2017-10-06 12:33:17 +0200 |
| commit | fb45ec112ebdf6f18143b844e317a555f14e3b74 (patch) | |
| tree | 3177e9781caff6d34c0ff6fc4536e8b0d59aa37c /plugins | |
| parent | 6bfa989253a3ec5563b07c5b14661d6b8dfebd6b (diff) | |
| parent | c5aca4005faf74d99091ef29257cbed6a53a12d4 (diff) | |
Merge PR #1124: Extraction: reduce atomic eta-redexes (solves indirectly BZ#4852)
Diffstat (limited to 'plugins')
| -rw-r--r-- | plugins/extraction/mlutil.ml | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/plugins/extraction/mlutil.ml b/plugins/extraction/mlutil.ml index a4c2bcd883..b16b430a81 100644 --- a/plugins/extraction/mlutil.ml +++ b/plugins/extraction/mlutil.ml @@ -769,6 +769,20 @@ let eta_red e = else e | _ -> e +(* Performs an eta-reduction when the core is atomic, + or otherwise returns None *) + +let atomic_eta_red e = + let ids,t = collect_lams e in + let n = List.length ids in + match t with + | MLapp (f,a) when test_eta_args_lift 0 n a -> + (match f with + | MLrel k when k>n -> Some (MLrel (k-n)) + | MLglob _ | MLexn _ | MLdummy _ -> Some f + | _ -> None) + | _ -> None + (*s Computes all head linear beta-reductions possible in [(t a)]. Non-linear head beta-redex become let-in. *) @@ -1053,6 +1067,10 @@ let rec simpl o = function simpl o (MLcase(typ,e,br')) | MLmagic(MLdummy _ as e) when lang () == Haskell -> e | MLmagic(MLexn _ as e) -> e + | MLlam _ as e -> + (match atomic_eta_red e with + | Some e' -> e' + | None -> ast_map (simpl o) e) | a -> ast_map (simpl o) a (* invariant : list [a] of arguments is non-empty *) |
