Skip to content

zazedd/zaml

Repository files navigation

A type-inferred, statically typed functional programming language inspired by OCaml and Lambda calculus.

Documentation

Syntax

<ident> ::= words

<expr> ::= <const>
       | <expr> <bop> <expr>
       | "let" <ident> (<ident>*)? "=" <expr>
       | "let" <ident> "=" <expr> "in" <expr>
       | "if" <expr> "then" <expr> "else" <expr>
       | "fun" <ident>+ "->" <expr>
       | <const> (<const>)+
        
<bop> ::= "+" | "++" | "-" | "*" | "/" | "%" | "@" | "::" | "==" | "!=" | "<" | "<=" | ">" | ">="

<const> ::= <simple_expr>
        | <ident>
        | "[" <expr_list>? "]"
        | int ".." int
        | "(" <expr> ")"

<expr_list> ::= <expr> (";" <expr_list>)?

<simple_expr> ::= int
              | char
              | str
              | unit
              | true
              | false

Running

There are two options for running zaml:

-> Running the REPL:

dune exec zaml

-> Interpret from a .zml file:

dune exec zaml example.zml

Testing

dune runtest

TODO list

-> Next-up

  • Better Syntax Errors
    • Line Positions
    • Character Positions
      • REPL
      • Intepreter (they don't reset for some reason)

-> Core Language

  • Evaluation
  • Let variable expressions
  • Let function expressions
  • Let tuple with destructuring
  • Lambda expressions
  • If expressions
  • Partial Applications
  • Match expressions
  • Algebraic effects
  • Ranges (1..31 -> [1; 2; ... 30; 31])
  • Standard library
    • Universal print function
    • ! (or not, function for booleans)
    • Figure out what else to include
  • Binary operators
    • Universal ops
      • ==
      • !=
      • > , =>
      • <, =<
    • Int ops
      • -
      • -
      • -
      • /
      • %
    • String ops
      • ++ (string concat)
      • I don't know yet
    • 'a list
      • @ (append)
      • :: (cons)
  • Garbage Collection

-> Types

  • Typechecking (Generalized Hindley-Milner (inspired by Didier Remy))
  • Refinement types
  • Union types
  • Algebraic data types
  • Data types
    • Unit
    • Int
    • Bool
    • Char
    • Float
    • String
    • Var
    • Arrow (x -> y)
    • Product (tuples)
    • 'a list
    • 'a array