Giter VIP home page Giter VIP logo

sml-system-t's Introduction

System T

This is an implementation of the language T from PFPL. It uses the CMU ABT library (the one used in the 15-312 course at CMU).

The aim is to closely follow the description in PFPL. All typing rules can be found in src/statics/typechecker.sml and all dynamics rules in src/dynamics/dynamics.sml somewhere close to the corresponding lines of code.

Building and running

You need smlnj to build along with ml-lex and ml-yacc. Given that you have these installed, just make in the project directory. If all goes well you should find the executables bin/system-t and bin/repl. Here is an example repl session:

$ ./bin/repl
> (\(x:nat) s(x))(s(s(z)))
Step: s(s(s(z)))
s(s(s(z))) : nat
> \ (x:nat) s(s(x))
lam{nat}([email protected](s(x@2))) : arr(nat; nat)
> (\ (f : nat -> nat) \ (x : nat) f(x))(\ (x:nat) s(x))(s(z))
Step: ap(lam{nat}([email protected](lam{nat}([email protected](x@7)); x@6)); s(z))
Step: ap(lam{nat}([email protected](x@10)); s(z))
Step: s(s(z))
s(s(z)) : nat
> \ (f:nat->nat) s(f)
Type error: s can be only applied to a nat.
> rec s(s(s(z))) {z => z | s(u) with v => s(s(s(v)))}
Step: s(s(s(rec(z; [email protected]@8.s(s(s(x@8))); s(s(z))))))
Step: s(s(s(s(s(s(rec(z; [email protected]@12.s(s(s(x@12))); s(z))))))))
Step: s(s(s(s(s(s(s(s(s(rec(z; [email protected]@16.s(s(s(x@16))); z))))))))))
Step: s(s(s(s(s(s(s(s(s(z)))))))))
s(s(s(s(s(s(s(s(s(z))))))))) : nat

Using the bin/system-t executable you can execute the T program in a file. There is a sample program in examples/sample.t. Executing it yields the following result.

$ ./bin/system-t examples/sample.t
s(s(s(s(z))))

Note that instead of โ†ช we use =>.

I have followed the homework solutions to CMU's 15-312. The ABT library is almost directly taken from the solutions that can be found on the course website as well as some of the other files (e.g. src/parser/parsestates.sml).

sml-system-t's People

Contributors

ayberkt avatar joom avatar

Stargazers

Anton Trunov avatar vtheno avatar april avatar Sandy Vanderbleek avatar Zeeshan Lakhani avatar Xuan Bi avatar Daniel Mendler avatar  avatar Mario Rodas avatar Jon Sterling avatar Juan Bono avatar

Watchers

Jon Sterling avatar Mario Rodas avatar James Cloos avatar  avatar  avatar  avatar

Forkers

bixuanzju

sml-system-t's Issues

Read from file

The current implementation only features a repl. Add the capability to read the T expression from a file and execute it.

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.