This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Copyright © 2023 Anne Redko */ | |
/* Under the MIT License. https://mit-license.org/ */ | |
#include <assert.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <ctype.h> | |
#include <stdint.h> | |
#include <stddef.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# by coinconclusive. in public domain. | |
from __future__ import annotations | |
from dataclasses import dataclass | |
from typing import ClassVar | |
@dataclass | |
class Lam: | |
name: str | |
body: Expr | |
def __str__(self): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// a very minimal instruction set. | |
// it has just enough operations to implement a recursive | |
// fibonacci function - what a coincidence :D | |
// NOTE: in my VM, i don't use an `enum`. | |
// this is just for simplicity. | |
#[derive(Clone, Copy, Debug)] | |
enum Instruction { | |
LoadInt { dst: u8, value: i16 }, | |
Copy { dst: u8, src: u8 }, | |
Add { dst: u8, src1: u8, src2: u8 }, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(* Compile with: | |
$ ocamlfind ocamlc -package angstrom,stdio -linkpkg tychk.ml -o tychk | |
Example use: | |
$ ./tychk <<EOF | |
> let f = (fun x -> x) : forall a. a -> a | |
> in f f | |
> EOF | |
input : forall a. a -> a | |
*) |