abnv, I ported @mattmight’s CPS conversion code (https://matt.might.net/articles/cps-conversion/) to #Haskell and after some fighting with the type system, it worked! To make the interpreters work with the Cont monad, I had to remove recursive lets and hence, functions being able to call themselves recursively, but the rest works fine.
The attached images show the conversion of the Fibonacci function into the CPS version.
Add comment