title: Linear types in OCaml
body: <p><a href="http://www.rust-lang.org/" rel="nofollow noreferrer">Rust</a> has a linear type system. Is there any (good) way to simulate this in OCaml? E.g., when using ocaml-lua, I want to make sure some functions are called only when Lua is in a specific state (table on top of stack, etc).</p>
  
  <p><strong>Edit</strong>: Here's a recent paper about resource polymorphism relevant to the question: <a href="https://arxiv.org/abs/1803.02796" rel="nofollow noreferrer">https://arxiv.org/abs/1803.02796</a></p>
  
  <p><strong>Edit 2</strong>: There are also a number of articles about session types in OCaml available, including syntax extensions to provide some syntactic sugar.</p>