Giter Site home page Giter Site logo

mgechev / typed-calc Goto Github PK

View Code? Open in Web Editor NEW
34.0 5.0 3.0 29 KB

Interpreter for simply typed lambda calculus implemented in JavaScript λ

Home Page: https://blog.mgechev.com/2017/08/05/typed-lambda-calculus-create-type-checker-transpiler-compiler-javascript/

JavaScript 100.00%
lambda-calculus interpreter type-system

typed-calc's Introduction

Simply Typed Lambda Calculus

A type checker and interpreter for simply typed lambda calculus written in JavaScript.

Example

The following program:

(λ a: Int → a) if (λ a: Int → iszero a) pred 0 then succ 0 else 0

Is correct and evaluates to 0.

How to use?

Interpreter

$ node index.js demo/correct1.lambda

0

Compiler

$ node index.js compile demo/correct1.lambda

(function(a) {
  return a;
})(
  (function(a) {
    return a === 0;
  })(0 - 1)
    ? 0 + 1
    : 0
);

License

MIT

typed-calc's People

Contributors

mgechev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

typed-calc's Issues

Transpile lazy evaluation properly

The transpilation to JavaScript of the following construct will fail at the moment.

(λ a: Nat → a)
  (if
    (λ a: Nat → iszero a) pred 0
  then
    (λ a: Nat → succ a)
  else
    (λ a: Nat → pred a))
  0

Termination

Hi,

Does the interpreter has any support to guarantee program termination ? Thanks.

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.