Skip to content
/ MLem Public

πŸ‘¨πŸΌβ€πŸ’»πŸ‘… A Tiny ML-like language for research purposes

Notifications You must be signed in to change notification settings

giulioz/MLem

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

23 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

MLem

Meta Language Extensions and Manipulation

logo

Syntax

Whole program is a big expression, use parentheses to avoid ambiguities.

  • let binding
let name = value; expression
  • Function apply β€” functions have only one parameter
inc 2
  • Lambda abstraction
\x -> x
  • Pattern matching
match exp with
| case -> value
| _ -> fallback
  • Data Types

    • Numeric integer literal number
    • Tuples (a,b,...)
    • String literal, between ""
  • Custom Types:

type Boolean = true | false;
type MaybeTwo = Just of number * number | Nothing;

Use Y Combinator for recursion (native recursion not yet supported).

Example program

type Boolean = true | false;
type MaybeTwo = Just of number * number | Nothing;

let Y = \f -> ((\x -> (x x)) (\y -> (f (\x -> ((y y) x)))));
let sub = \x -> \y -> (sum x (neg y));

let fibonacci = Y (\f -> \x ->
  match x with
  | 0 -> 0
  | 1 -> 1
  | x -> (
    let a = (sub x) 1;
    let b = (sub x) 2;
    let fa = f a;
    let fb = f b;
    sum fa fb
  )
);

match (fibonacci 8) with
| 21 -> true
| _ -> false

Usage

Place your code in test.mml.

yarn install
yarn start

Rebuild grammar

yarn build

About

πŸ‘¨πŸΌβ€πŸ’»πŸ‘… A Tiny ML-like language for research purposes

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published