by Kootle · 8y ago · 0 comments
https://github.com/tweag/ghc/tree/linear-types
However, to allow the compiler to optimise pure operations to impure ones, I don't think linear types are sufficient. You need something like uniqueness types.
x = doSomething(x) + 1
Can be written to not overwrite x int x2 = doSomething(x) + 1
This is equivalent in some ways to Haskell let x' = doSomething x + 1
However, I know that in Haskell, evaluating 'doSomething x' will not turn off the computer, display anything to the user, or launch missiles. I have no idea what evaluating 'doSomething(x)' does in C++. It may add things to caches, exit the program, etc.