GithubHelp home page GithubHelp logo

ilya-klyuchnikov / tapl-scala Goto Github PK

View Code? Open in Web Editor NEW
175.0 8.0 22.0 662 KB

Code from the book "Types and Programming Languages" in Scala

Scala 100.00%
tapl programming-languages type-checking type-inference

tapl-scala's Introduction

TAPL in Scala

Roadmap

  1. tapl.arith - (chapters 3, 4).
  2. tapl.untyped (chapters 5-7).
  3. tapl.fulluntyped (chapters 5-7).
  4. tapl.tyarith (chapter 8).
  5. tapl.simplebool (chapter 10).
  6. tapl.fullsimple (chapter 9 and 11).
  7. tapl.fullref (chapter 13, 18)
  8. tapl.fullerror (chapter 14)
  9. tapl.rcdsubbot (chapter 15)
  10. tapl.fullsub (chapters 15-17)
  11. tapl.bot (chapter 16)
  12. tapl.fullequirec (chapter 20).
  13. tapl.fullisorec (chapter 20).
  14. tapl.equirec (chapter 21).
  15. tapl.recon (chapter 22).
  16. tapl.fullrecon (chapter 22).
  17. tapl.fullpoly (chapters 23, 24).
  18. tapl.fullomega (chapters 23, 29, 30).
  19. tapl.fullfsub (chapters 26, 28).
  20. tapl.fullfomsub (chapters 26, 31).
  21. tapl.fullfomsubref (chapter 27) combination of all systems from the book.

Code structure

The code structure for each implementation follows the original code structure and consists of 4 files:

  • syntax.scala - AST, contexts, commands, pretty-printing.
  • parser.scala - parsing.
  • core.scala - evaluator and typer.
  • demo.scala - the main application for processing input files.

Running

sbt
> run

Multiple main classes detected, select one to run:

 [1] tapl.fullisorec.FullIsorecDemo
 [2] tapl.rcdsubbot.RcdSubBotDemo
 [3] tapl.arith.ArithDemo
 [4] tapl.simplebool.SimpleBoolDemo
 [5] tapl.equirec.EquirecDemo
 [6] tapl.tyarith.TyArithDemo
 [7] tapl.untyped.UntypedDemo
 [8] tapl.fullfsub.FullFSubDemo
 [9] tapl.fullpoly.FullPolyDemo
 [10] tapl.recon.ReconDemo
 [11] tapl.fullfomsub.FullFomSubDemo
 [12] tapl.fullerror.FullErrorDemo
 [13] tapl.fulluntyped.UntypedDemo
 [14] tapl.fullsub.FullSubDemo
 [15] tapl.fullequirec.FullEquirecDemo
 [16] tapl.fullrecon.FullReconDemo
 [17] tapl.fullref.FullRefDemo
 [18] tapl.fullomega.FullOmegaDemo
 [19] tapl.fullsimple.FullSimpleDemo
 [20] tapl.fullfomsubref.FullFomSubRefDemo
 [21] tapl.bot.BotDemo

Enter number: 21

[info] Running tapl.bot.BotDemo
====================
(lambda x: Top. x): Top -> Top;
||
\/
(lambda x: Top. x): Top -> Top;
====================
((lambda x: Top. x) (lambda x: Top. x)): Top;
||
\/
(lambda x: Top. x): Top -> Top;
====================
((lambda x: Top -> Top. x) (lambda x: Top. x)): Top -> Top;
||
\/
(lambda x: Top. x): Top -> Top;
====================
(lambda x: Bot. x): Bot -> Bot;
||
\/
(lambda x: Bot. x): Bot -> Bot;
====================
(lambda x: Bot. x x): Bot -> Bot;
||
\/
(lambda x: Bot. x x): Bot -> Bot;

> run-main tapl.fulluntyped.UntypedDemo progs/fulluntyped.tapl
[info] Running tapl.fulluntyped.UntypedDemo progs/fulluntyped.tapl
====================
tru;
||
\/
(lambda t. lambda f. t);
====================
fls;
||
\/
(lambda t. lambda f. f);
====================
(tru tru);
||
\/
(lambda f. lambda t. lambda f'. t);
====================
(tru fls);
||
\/
(lambda f. lambda t. lambda f'. f');
====================
(test tru v w);
||
\/
((lambda m. lambda n. (lambda t. lambda f. t) m n) v w);
...

tapl-scala's People

Contributors

ilya-klyuchnikov avatar svenkeidel 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  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  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  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tapl-scala's Issues

PTS (pure type systems)

For educational purposes it is good to have just PTSs. Ideally, I would like to have the whole lambda cube.

parser in antlr

This will allow to easily port TAPL into all other languages supported by antlr

Uniform code

Re-arrange, re-structure all the examples in such a way, that different type-checkers are easily comparable.
Solution: introduce some canonical way in which case classes, clauses are ordered. Baseline: start from the "fullest" TS - fullfomsubref

Another option: use alphabetical order.

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.