Module Lambda_lib.Ast

type name = string
type binop =
  1. | Add
    (*

    +

    *)
  2. | Sub
    (*

    -

    *)
  3. | Mul
    (*

    *

    *)
  4. | Div
    (*

    /

    *)
  5. | Mod
    (*

    %

    *)
  6. | Eq
    (*

    =

    *)
  7. | Neq
    (*

    <>

    *)
  8. | Lt
    (*

    <

    *)
  9. | Gt
    (*

    >

    *)
  10. | Leq
    (*

    <=

    *)
  11. | Geq
    (*

    >=

    *)

Binary operators

type 'name t =
  1. | Var of 'name
    (*

    Variable x

    *)
  2. | Abs of 'name * 'name t
    (*

    Abstraction λx.t

    *)
  3. | App of 'name t * 'name t
    (*

    Application f g

    *)
  4. | Int of int
    (*

    Integer literal 42

    *)
  5. | BinOp of binop * 'name t * 'name t
    (*

    Binary operation e1 + e2

    *)
  6. | If of 'name t * 'name t * 'name t option
    (*

    Conditional if cond then e1 else e2

    *)
  7. | Let of bool * 'name * 'name t * 'name t
    (*

    Let binding let (rec) x = e1 in e2. bool indicates recursion

    *)

The main type for our AST