ren-lang / compiler / Ren.Compiler


type alias Compiler error =
String -> Result error String


type alias Toolchain error meta =
{ parse : String -> String -> Result error (Ren.AST.Module.Module meta)
, desugar : Ren.AST.Module.Module meta -> Ren.AST.Module.Module meta
, validate : Ren.AST.Module.Module meta -> Result error (Ren.AST.Module.Module meta)
, check : Ren.AST.Module.Module meta -> Result error (Ren.AST.Module.Module meta)
, optimise : Ren.AST.Module.Module meta -> Ren.AST.Module.Module meta
, emit : Ren.AST.Module.Module meta -> String 
}


type alias Error =
Error

run : String -> Toolchain error meta -> Compiler error

Chains together the various steps of a given toolchain to be run against some Ren code input.

untyped : Toolchain Error Ren.Data.Span.Span

typed : Toolchain Error Ren.Data.Span.Span

typecheck : Toolchain Error Ren.Data.Span.Span

This toolchain doesn't emit code at the end; it type checks a module and then emits a list of declarations and their type. Of course, declarations must be type annotated in order to be type checked at all so running this toolchain doesn't provide you with any information you didn't already know, but it is handy to have around to test the type checker is working without flooding the console with emitted pretty-printed code.

custom : Basics.Bool -> List (Desugar.Transformation Ren.Data.Span.Span) -> List (Optimise.Optimisation Ren.Data.Span.Span) -> Emit.Target -> Toolchain Error Ren.Data.Span.Span