ren-lang / compiler / Ren.Compiler.Optimise


type alias Optimisation meta =
meta -> Ren.AST.Expr.ExprF (Ren.AST.Expr.Expr meta) -> Ren.AST.Expr.ExprF (Ren.AST.Expr.Expr meta)

An optimisation is any function that takes both the metadata and expression node in the AST and returns a new AST node; usually a simplified version.

This is actually the same type as a Transformation, but I find it useful to disambiguate between functions that desugar or modify the AST and ones that attempt to simplify or eliminate nodes.

run : List (Optimisation meta) -> Ren.AST.Module.Declaration meta -> Ren.AST.Module.Declaration meta

operators : meta -> Ren.AST.Expr.ExprF (Ren.AST.Expr.Expr meta) -> Ren.AST.Expr.ExprF (Ren.AST.Expr.Expr meta)

This optimisation attempts to evaluate operators at compile-time. This mostly just optimises away operations on literals, like computing the expression 1 + 1.