Code Monkey home page Code Monkey logo

jml's Introduction

JML

An experimental Parser and Java-Interpreter for a functional language inspired by SML

This is a toy project that I've created to learn more about functional programming languages and particularly Standard ML. Although this interpreter lacks some key features of SML like compile-time type checking and type inference, I've implemented much of the language's core features and added means to interact with Java-Objects.

I'm not actively working on this project and did never have any serious plans with it. If you're interested in functional programming on the JVM take a look at Scala that has been influenced by SML.

Build from source:

mvn clean install

Run the interactive read-eval-print-loop:

java -jar target/jml-*-jar-with-dependencies.jar

Now type in expressions and declarations separated by ";" and terminated by ";;"

Define the function "factorial"

fun factorial 0 = 1
	| factorial n = n * factorial (n-1)
;;

and then call it factorial 10 ;;

The function that append an element to a list might be implemented like this:

val rec append = fn
		(list,x) => 
		case list of
			nil => x::nil
			|
			h::t => h::(append(t,x))

append ([1,2,3],4)

will then return [1,2,3,4]. Note that nil is a synonym for the empty list [], [1] equals 1::nil and [1,2] equals 1::2::nil and so on.

The language's grammar is defined in FL.g.

See test.fl and global.fl to get a glimpse of the supported syntax and functionality.

jml's People

Contributors

matatata avatar

Watchers

James Cloos 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.