optimizationfunctional-programmingcompiler-constructionimmutabilityssa

Is a functional program already in SSA form?


Recently, I've been wanting to create a small (educational) functional, optimizing compiler. For the optimizing portion, I want to use SSA. The thing is that (most, as far as I know) functional programming languages have immutable variables (by default), so every variable is assigned only once like in SSA. Would SSA be needed? Is a functional program (in Haskell for example) already in SSA form?


Solution

  • Yes, programs written in purely functional languages (eg. Haskell) are in SSA form. You can find more explanation in this research paper.

    Note that this is not true for all functional languages. For example, OCaml allows programmers to mutate variables and write imperative blocks (which makes OCaml not a pure functional language), breaking the SSA form.