Skip to content
This repository has been archived by the owner on Oct 18, 2021. It is now read-only.

Let-of-bottom optimisation #216

Open
plt-amy opened this issue Nov 4, 2019 · 1 comment
Open

Let-of-bottom optimisation #216

plt-amy opened this issue Nov 4, 2019 · 1 comment
Labels
enhancement Optimiser Issues and PRs relating to the optimiser

Comments

@plt-amy
Copy link
Member

plt-amy commented Nov 4, 2019

According to Amulet's semantics, the following is a valid optimisation:

let x : t = e in
...
(* => *)
let x : t = e in
match x {}
(* iff t is empty *)

This is mostly a code size/compiler performance optimisation: the following program would get DCE'd to all but the call to bot, whereas currently it includes all of the IO/Exception machinery:

open import "prelude.ml"

type void = |
external val bot : () -> void = "error"

let _ =
  let x = bot ()
  put_line "can't get here"

After we have attributes, we could even mark functions as returning bottom, which would let us optimise uses of (import "amulet/exception.ml").throw.

@plt-amy plt-amy added enhancement Optimiser Issues and PRs relating to the optimiser labels Nov 4, 2019
@plt-amy
Copy link
Member Author

plt-amy commented Nov 4, 2019

I think the "empty type" is a good approximation but it might actually be a red herring. What we want is support for eliminating tails of bottoming computations generally (Amulet exceptions, compiler-generated error calls, infinite recursion, empty matches, "returning" an empty type, etc..), which is bloody hard to do in a well-typed way.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement Optimiser Issues and PRs relating to the optimiser
Projects
None yet
Development

No branches or pull requests

1 participant