-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Compiler backend #9
Comments
Edwin Brady's thesis, Practical Implementation of a Dependently Typed Functional |
I'd definitely want to have some nice documentation about the compiler like MLton's at some stage! This would make contributing easier for newcomers. |
Nice advice from @evincarofautumn:
|
Minor correction: Sixten has unboxed types but not dependent types (at least the Readme doesn't say so). |
It actually does have dependent types! @ollef just isn't promoting it that way (yet?). If you have a look at the core syntax, you'll see that it describes a dependently typed lambda calculus. -- | Expressions with meta-variables of type @m@ and variables of type @v@.
data Expr m v
= Var v
| Meta m (Vector (Plicitness, Expr m v))
| Global QName
| Con QConstr
| Lit Literal
| Pi !NameHint !Plicitness (Type m v) (Scope1 (Expr m) v)
| Lam !NameHint !Plicitness (Type m v) (Scope1 (Expr m) v)
| App (Expr m v) !Plicitness (Expr m v)
| Let (LetRec (Expr m) v) (Scope LetVar (Expr m) v)
| Case (Expr m v) (Branches Plicitness (Expr m) v) (Type m v)
| ExternCode (Extern (Expr m v)) (Type m v)
| SourceLoc !SourceLoc (Expr m v)
deriving (Foldable, Functor, Traversable)
-- | Synonym for documentation purposes
type Type = Expr |
It would be nice to actually compile Pikelet programs!
Initial sketch of passes
We'll probably want some intermediate representations like MLton to get the higher level Pikelet code to be in better shape for passing to a back-end.
Unresolved questions
We would like to do more work on the type system to make efficient code-gen easier. For example tracking coeffects such as usage mutliplicities (#7), and data flow annotations (allowing us to partially evaluate code at compile time). Regions would also be handy at some stage.
Another issue we'll have to face at some time is garbage collection. Ultimately it would be nice to not have to force users to use a specific allocation strategy, but figuring out how this interacts with multiplicities might be tricky. Until we have a better idea it might be be easier just to use something like the Boehm-Demers-Weiser GC in the interim.
Possible codegen targets
Some possible targets for codegen are as follows:
A JIT might be handy as it would allow us to embed Pikelet in existing Rust codebases. This could help us gain adoption without needing to convince folks to switch to an entirely new language in the mid-term.
Resources:
Programming Language
into Efficient Low-Level Code
Example compilers in Rust
Sixten is another functional language with dependent types and unboxed data types. Might be worth looking there for inspiration too!
The text was updated successfully, but these errors were encountered: