Giter Club home page Giter Club logo

lambdasc's Introduction

𝝺sc Interpreter

This is a simple interpreter for $\lambda_{sc}$, a calculus for scoped effects & handlers.

The interpreter supports parsing, type inference, evaluation, and printing.

Getting Started

Make sure you have stack installed.

Build the interpreter:

stack build

Run the interpreter with a given file using the following command:

stack exec lambdaSC-exe inputFileName

For example, running stack exec lambdaSC-exe test/intro.sc gives the following output:

[PARSE SUCCESS 🥳]:
  7 statements found
[TYPE INFERENCE SUCCESS 🥳]: 
  f : ∀a:Eff. Int -> Int ! a
  g : ∀a:Eff. Int -> Int ! a
  concatMap : ∀a:*. ∀b:*. ∀c:Eff. List a -> ((a -> List b ! c) -> List b ! c) ! c
  hND : ∀a:*. ∀b:Eff. a ! <fail; choose | b> => List a ! b
  Int ! a
  List List Char ! a
  List List Char ! a
[EVALUATION RESULTS 🥳]:
 15
 ["heads", "tails"]
 ["heads", "tails"]

Files Structure

There are three main directories:

  • src : source code of the interpreter
    • Context.hs : context definition and management
    • Syntax.hs : syntax definition and auxiliary functions
    • Evaluation.hs : implementation of the operational semantics
    • TypeInference.hs : implementation of the type inference algorithm
    • Substitution.hs : substitution for the type inference
    • Lexer.hs : lexer
    • Parser.hs : parser
    • PrettyPrinter.hs : pretty printer
  • app : main program
    • Main.hs : the main program for running the interpreter
  • test : 𝝺sc examples
    • intro.sc : an introduction file to the syntax (the syntax supported by the interpreter is slightly different from the paper)
    • once.sc : nondeterminism with once (paper Section 2 and 3)
    • inc.sc : forwarding for the handler of inc (paper Section 7)
    • exceptions.sc : exceptions (paper Section 9.1)
    • localread.sc : reader with local (paper Section 9.2)
    • cut.sc : nondeterminism with cut (paper Section 9.3)
    • depth.sc : depth-Bounded Search (paper Section 9.4)
    • parser.sc : parser (paper Section 9.5)
    • localstate.sc : local state

Evaluating the Artifact

We propose to evaluate the artifact by running stack exec lambdaSC-exe inputFileName and replacing inputFileName with each file name in the test directory. This will show the results of all non-trivial examples appearing in the paper.

The correspondence between examples in the paper and test files is shown as follows:

  • test/once.sc contains some examples in Section 2 and 3 that use non-determinism and once.
  • test/inc.sc contains the examples in Section 7 including both the problematic and correct implementations of forwarding for the handler of inc
  • test/exceptions.sc contains the examples in Section 9.1 including catch as a handler and catch as a scoped effect
  • test/localread.sc contains the examples in Section 9.2 including local as a handler and local as a scoped effect
  • test/cut.sc contains the examples in Section 9.3
  • test/depth.sc contains the examples in Section 9.4
  • test/parser.sc contains the examples in Section 9.5

lambdasc's People

Contributors

thwfhk avatar

Stargazers

Bruno Dias avatar aramya avatar Nikita avatar Amir M. Saeid avatar

Watchers

 avatar

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.