Code Monkey home page Code Monkey logo

pizzaml's Introduction

PizzaML

This is a very silly project to make Standard ML more appealing to various groups including:

  • Systems programmers
  • Rust programmers
  • People born after 1973

At the moment this repository contains the skeleton of a transpiler from PizzaML's Rust-like syntax to something vaguely resembling Standard ML.

Given this input file in PizzaML:

// examples/hello.pz
fn main() {
    print("Hello world!\n");
    print("We can print ;)\n");
}

We can compile it to SML as follows:

$ cargo build --release
$ ./target/release/pizza_ml examples/hello.pz
$ cat output.sml

The contents of output.sml should be something like the following:

fun main () = let
val _ = (TextIO.print "Hello world!\n");
val _ = (TextIO.print "We can print ;)\n");
in ()
end;

You can then compile this to a binary using a Standard ML compiler, e.g. PolyML

$ polyc output.sml -o output
$ ./output

pizzaml's People

Contributors

michaelsproul avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

pizzaml's Issues

Make sure function bodies are blocks

At the moment any old expression can be the body of a function, e.g.

fn func(x: int, y: int) 5

We should check that the expression after a function is actually a { } block

Type-translation table

There needs to be a table to translate PizzaML type names to SML ones. I wouldn't mind using type names with capitals like Int and String, instead of int and string.

Polymorphic types

This might be a bit tricky:

  • Parse Rust's <T> syntax
  • Convert type variables to 'T

Alternative basis library

It would be cool to have a standard library that roughly follows Rust's, but gets translated into not-too-convoluted calls into SML's basis library.

Implementation will likely require a combination of direct translation (e.g. print => TextIO.print), and shimming (e.g. println s = TextIO.print (s ^ "\n"))

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.