Git Product home page Git Product logo

mt's Introduction

etc

Erlang Type Checker

Basics

# Installation
git clone https://github.com/nachivpn/mt.git
cd mt/etc/ && rebar3 escriptize

# Simple usage evaluation example
./etc hello.erl

# Partial evaluation + Type Inference example
./etc +pe hello_pe.erl

# To see the result of code generated by partial evaluation 
./etc +pe -P hello_pe.erl #produces hello_pe.P file

# (only) partial evaluation example
./etc +pe +noti -P hello_pe.erl

Documentation

Currently there's very little documetation on the source code and implementation details. However, the thesis work has been documented closely at multiple stages. If you're curious, check out the reports section: https://github.com/nachivpn/mt/tree/master/reports

Disclaimer

This project is the result of a master thesis at Chalmers University. The implementation is a prototype to demonstrate the scientific ideas and has not been tested thouroughly. The type checker supports a large part of the language, but the partial evaluator doesn't and may break easily. It is not at all production ready!

mt's People

Contributors

nachivpn 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

Watchers

 avatar  avatar  avatar  avatar

Forkers

vrnithinkumar

mt's Issues

Pretty printing function types

Currently function types look like Haskell types, they need to look like "Erlang types"! That is: (a,b) -> a instead of a -> (b -> c)

Bug in clause unification!

Clause unification uses "pairwiseChunk" - this is ridiculous - and leads to an error. for example this will pass the type checker:

foo() -> 1.0;
foo() -> 1.0;
foo() -> true;
foo() -> false.

Instead, it should make a "chain" of unification constraints..

Support numeric types

Requires implementation of (basic) type classes. Being able to type expressions like int + float depends on this.

Incorrect type is inferred if the type of let binding is a type variable

Inferred type of lets(x,app(idterm(y),int(5)),X) is A !!

Trace:

Type of y = {tvar,#Ref<0.1275695646.2152202243.105277>}
Fresh Type of y = {tvar,#Ref<0.1275695646.2152202243.105277>}
App Type1 = {funt,[{tvar,#Ref<0.1275695646.2152202243.105277>}],
                  {tvar,#Ref<0.1275695646.2152202243.105277>}}
 Constraints1 = []
App Type2 = {bt,int}
 Constraints2 = []
LETX Type1 = {tvar,#Ref<0.1275695646.2152202243.105280>}
 Constraints1 = [{{funt,[{tvar,#Ref<0.1275695646.2152202243.105277>}],
                        {tvar,#Ref<0.1275695646.2152202243.105277>}},
                  {funt,[{bt,int}],
                        {tvar,#Ref<0.1275695646.2152202243.105280>}}}]
----------Env = []
Type of x = {forall,{tvar,#Ref<0.1275695646.2152202243.105280>},
                    {tvar,#Ref<0.1275695646.2152202243.105280>}}
Fresh Type of x = {tvar,#Ref<0.1275695646.2152202243.105286>}
LETX Type2 = {tvar,#Ref<0.1275695646.2152202243.105286>}
 Constraints2= []
A
Generated constraints are:
(B)->B :==: (int)->C
Inferred type: A

Support single recursion

Do a pre-pass and assign a fresh type to each function in the environment before attempting to infer the types of each function

Bring variable into scope if bound on all branches

Currently, this program is rejected although it is semantically valid:

x() -> 
    if
      true -> X = 1;
      false -> X = 3
    end,
    X.    %%line 24

with error:

test.erl: error in parse transform 'etc': {"Type Error: 'X' not bound on line 24

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.