Skip to content

andrewhickman/small-lang

Folders and files

NameName
Last commit message
Last commit date
Sep 1, 2020
Dec 24, 2019
Dec 24, 2019
Dec 23, 2019
Sep 1, 2020
Nov 17, 2019
Sep 1, 2020
Dec 23, 2019
Dec 15, 2019
Dec 23, 2019
Sep 1, 2020
Jun 6, 2022
Sep 1, 2020
Nov 8, 2019
Nov 8, 2019
Dec 24, 2019

Repository files navigation

Small-lang

A minimal compiler using the mlsub type system

Features

Record types

let record = { field: 1 }
in record.field

Enum types

let enum = [some: 1]
in match enum with [
  some: val => val,
  none => 0,
]

Recursive functions

let cmp = import "cmp" in
let math = import "math" in

let rec fibonacci = func n =>
  if cmp.eq n 0 then 0
  else if cmp.eq n 1 then 1
  else math.add
    (fibonacci (math.sub n 1))
    (fibonacci (math.sub n 2))
in fibonacci 14