https://github.com/giulioz/mlem
👨🏼💻👅 A Tiny ML-like language for research purposes
https://github.com/giulioz/mlem
compiler functional haskell language ml nearley ocaml parser types
Last synced: about 1 month ago
JSON representation
👨🏼💻👅 A Tiny ML-like language for research purposes
- Host: GitHub
- URL: https://github.com/giulioz/mlem
- Owner: giulioz
- Created: 2019-07-15T13:39:41.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2023-07-12T00:23:39.000Z (almost 2 years ago)
- Last Synced: 2025-04-15T01:14:45.802Z (about 1 month ago)
- Topics: compiler, functional, haskell, language, ml, nearley, ocaml, parser, types
- Language: TypeScript
- Homepage:
- Size: 125 KB
- Stars: 6
- Watchers: 0
- Forks: 0
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# MLem
**Meta Language Extensions and Manipulation**

### 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
```