Skip to content

vertexcubed/MaML

Repository files navigation

MaML

MaML is a simple ML dialect inspired by OCaml and Standard ML, implemented in Kotlin. It is designed to be embedded into Java/Kotlin applications as a lightweight scripting language.

Installation

TODO: Create maven repository

Getting Started

To get started, create a new Interpreter object, and call run to execute code.

val code = "let rec factorial n = \n" +
            "  if n <= 1 then 1 \n" +
            "  else n * factorial (n - 1)"

val interp = Interpreter()
interp.run(code)

You can register external functions using the registerBuiltins method.

    external print_endline: string -> unit = "maml_println"
fun myFunc(arg: MValue): MValue {
    println(arg)
    return UnitValue
}

val interp = Interpreter()
interp.registerExternal("maml_println", ::myFunc)

Documentation

Documentation is available in this repository's wiki.

License

MaML is open source under the MIT license. See LICENSE for more information.

Reporting Issues

MaML is in active development, and bugs and issues are expected. Please report bugs on the issue tracker.

Roadmap

Core Language

  • Basic expression syntax - If statements, let expressions, functions
  • Type checking and type inference
  • Recursive functions
  • Builtin functions
  • Toplevel expressions
  • Algebraic Data Types
  • Pattern Matching
  • Custom infix functions
  • Multi argument builtin functions
  • Multi argument Type Constructors
  • Type aliases
  • Pattern exhaustiveness checking
  • List Sugar ([], x :: xs, etc.)
  • Records
  • Modules
    • Module Signatures / Interfaces
    • Module Functors
  • Exceptions

Additional Features

  • Asynchronous values?
  • Callbacks
  • REPL environment for command-line
  • Standard Library
    • Either
    • Format (Pretty printing)
    • Functors (Maybe)
    • Higher order functions - map, fold
    • Lazy
    • Lists
    • Maps
    • Monads
    • Options
    • Result
    • Sets
    • Stacks
    • Streams
    • Queues
  • Compiler
    • IR Bytecode
    • Virtual stack instead of JVM Call Stack
    • Tail Call Optimization

Not Planned

  • Iteration
  • Side effects / mutable values*
    • Lazy values might be the exception to this
  • Classes and objects
  • Polymorphic variants*
    • I might change my mind on this depending on how hard it is to implement.
  • Named function arguments
  • Garbage Collector
    • Out of scope for this project - let the JVM GC handle it.

About

A simple ML dialect implemented in Kotlin

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published