Linear types in OCaml
问题 Rust 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). Edti : Here's a recent paper about resource polymorphism relevant to the question: https://arxiv.org/abs/1803.02796 回答1: As suggested by John Rivers, you can use a monadic style to represent "effectful" computation in a way that hides the linear constraint in the effect API