Git Product home page Git Product logo

lambda-mountain's Introduction

Hi, I'm Andrew Johnson

All things considered... copy and paste is probably the best option.

2024 Roadmap (Working towards a verified kernel language)

Upcoming Planned Features

  • actually useful errors messages with code snippets and source location (mostly working on strict compiler)
  • arbitrary sized return values
  • parametric polymorphism

Request for Comment

If you feel like contributing to either LM or LSTS it would be enormously helpful to have anyone simply read a bit and ask a question. The projects are starting to grow to a size where it is hard to understand where a curious learner might get stuck. Different people have different backgrounds so it takes all shapes and sizes. Everyone is welcome, though I fear that the learning curves are still very steep.

lambda-mountain's People

Contributors

andrew-johnson-4 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

lambda-mountain's Issues

Make an assemble.lm optional build artifact.

Codegen is an implicit dependency in the build process. Alternative targets can be supported as either --target [target] if the target is bundled with the LM compiler, or alternatively with a --assembler [assembler.lm] arbitrary custom assembler.

The assembler must define a function assemble(options: S, program: S) which will then finish the compilation. The LM compiler in this case will still perform the functions of a parser, preprocessor, and build tool.

Typed LM

Typed LM Codegen is fairly different than the bootstrap release. I have pared down the bootstrap compiler to just tokenization and parsing. Now we should introduce typechecking before reconstructing the codegen. Also some of the optimizations from the bootstrap book can reduce memory use by 50%.

Search engine for functions / libraries

It would be nice to provide a frontend to search for existing libraries with functions that provide some functionality. This could be links to github repos that get downloaded or crates that get added as dependencies.

This would be most useful after types and ad-hoc polymorphism get implemented to avoid conflicts in the global namespace.

Typed macros as opposed to full functions

let or other functions that manipulate volatile locals like registers or stack can't be called with normal operational calling conventions. The code actually needs to be expanded inline like a macro, but that makes things like labels and local jumps potentially problematic. There are a host of problems here.

I think the correct solution is type-sensitive specialization, but that isn't available in the bootstrap compiler.

Two, Three, Four register bootstrap compiler

Only two registers are really needed to represent a cons cell. It might be an interesting exercise to try to generate a 2,3,4 register compiler version to see how flexible the register assignment strategy can be.

"I want to represent an S-Expression with 2 registers. Generate some code for me."

Smart Cons

(side effect 1)
(side effect 2)
return

is better than

(tail(
   (side effect 1)
   (side effect 2)
   return
))

"Namespace" rule contexts

asm!( mov( $0 %r12 ) )

is different from just

mov( $0 %r12 )

The asm! rule has it's own namespace and calling conventions.

Gradual Typing Option

Add a --gradual flag for the compiler to enable implicit casts into/out-of S-Expression representation.

Parser generator (bootstrap)

Bring this story to life:

rhs        := [a-z][_a-zA-Z0-9]*   //Variable
            | ( rhs* )             //Function Application
            | λ rhs* . rhs*        //Lambda Function
            | [^ ]+                //Literal Value

binding    := [a-zA-Z0-9]+ [:] [=] rhs \n

program    := binding*

example recursive descent parser:

  • top to bottom (previous rule candidates have higher precedence over following rule candidates)
  • terminal to non-terminal (terminal symbols have higher precedence over non-terminal symbols within same rule)
  • left to right (left symbols have higher precedence over right symbols within same rule)
  • this parser generator is for up-to free grammars and requires infinite lookahead in worst case
nibble-lhs := λ"a" a. a
nibble-rhs := λa "a". a
nibble-nonterminal := λ(nibble-lhs a) b. a b
nibble-empty := λ. "a"
nibble-tokens := λ(ident n) (eq _) (rhs r). (Assign n r)

Clarify rules for default Apply vs Chain behavior and Explicit vs Implicit arguments

Chain and Apply are the most primitive functional operations. They have default behaviors but there is also specialization to override that. Explicit vs Implicit arguments make this interesting too.

      Implicit    <->     Explicit
      ^                      ^
chain |                      | apply
      v                      v
      Implicit    <->     Explicit

After all the sugar gets taken off, f x just calls (chain implicits f x)

Inference for Simply Typed Lambda Calculus

The program should accept a special symbol ::infer that can be used for type inference. This term will be applied with a Type Context and a Term, returning a new Term.

Generalize the Chain Rule for Smart Cons

The chain rule for functions applies the function, otherwise it makes a Cons cell.
It would be nice if users could define custom chain rules.

( (App (: f (->(x y))) x) ... apply function ... )
custom chain rules go here
( (App l r) ... yield cons ... )

LM restricted interpreter based compiler

✓ Bootstrap Compile a CLI
✓ Bootstrap Compile a CLI that dumps S-Expression fragments
✓ Bootstrap Compile a CLI that normalizes then dumps S-Expression fragments
✓ Bootstrap Compile a CLI that parses, normalizes, then dumps S-Expression fragments
Bootstrap Compile a CLI that parses, normalizes, then assembles S-Expression fragments

Good test suite for bootstrap and release compiler

tests.boostrap/
   thetest.lm             #test to run
   thetest.lm.config  #compile time flags
   thetest.lm.args     #arguments to runtime
   thetest.lm.out       #expected stdout
   thetest.lm.err        #expected stderr
   testest.lm.errno    #expected exit code
tests.release/
   *

Phase Bootstrap for LM

  • ✓ car/cdr bootstrap for interpreter
  • interpreted codegen bootstrap
  • optimized binary generation from idyllic LM codebase

Deduplicate atoms

There are 100s of Apps in the compiler but only one is necessary.

REPL

REPL

lambda_mountain repl
> p := λx. x x
> p := λx x. x
> p a a
a
>

Support multiple frontend projections

LM can have an internal IR representation of assembler code. It would also be good to be able to read and write from different syntaxes. This starts to address the MxN problem of multiple frontends, multiple target platforms.

Internal Representation

  • Platform Specific Functionality
  • Platform Independent Logic

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.