Yes, this is very ugly. However, I managed to squeeze so much out of the original code, and make it really fast (though this could be even better). I think I might have gotten to the point where I cannot really make it go faster, but for a basic VM, I think this is bloody good as it is.
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
This gist contains an implementation for a typechecker for Quantitative Type Theory (QTT), in Isabelle/HOL. |
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
Closure conversion and monomorphisation by type erasure implemented on a Quantitative Dependently Typed Lambda Calculus. |
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 small typechecker using normalization by evaluation (NbE) for a Quantitative Dependently Typed Lambda Calculus (QDTLC). |
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
.DEFAULT: main.ice | |
ifdef tool | |
silice-make.py -s main.ice -b $@ -p basic,pmod -o BUILD_$(subst :,_,$@) -t $(tool) | |
else | |
silice-make.py -s main.ice -b $@ -p basic,pmod -o BUILD_$(subst :,_,$@) | |
endif | |
clean: | |
rm -rf BUILD_* |
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
/** | |
---------------------------------------------------------------- | |
// Interpreter callstack | |
type CallStack = { vars: { name: string, value: Value }[] }[] | |
---------------------------------------------------------------- | |
// A runtime value | |
type Value = Integer | Function | PrimFunction | |
type Integer = { type: 'Integer', value: int } | |
type Function = { type: 'Function', args: string[], block: ASTBlock } | |
type PrimFunction = { type: 'PrimFunction', val: (Value...) => Value } |
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
{-# LANGUAGE TypeFamilies #-} | |
{-# LANGUAGE MultiParamTypeClasses #-} | |
{-# LANGUAGE DataKinds #-} | |
{-# LANGUAGE ConstraintKinds #-} | |
{-# LANGUAGE KindSignatures #-} | |
{-# LANGUAGE NoStarIsType #-} | |
{-# LANGUAGE TypeApplications #-} | |
{-# LANGUAGE FlexibleInstances #-} | |
{-# LANGUAGE RecordWildCards #-} | |
{-# LANGUAGE TypeOperators #-} |
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
{-| Exercise: | |
- Step 1: | |
Write a program simulating an iterating machine: we for example feed a range | |
@[0..4]@ and an action @print@ and it must execute this action on all the | |
elements of the range. | |
Writing @iterate1 [4..9] print@ must output: | |
> 4 |
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
from discord.ext import commands | |
import discord | |
import sqlite3 | |
prefix = '#!' | |
client = commands.Bot(command_prefix=prefix) | |
print('Connecting to database...') | |
conn = sqlite3.connect('categories.db') | |
c = conn.cursor() |
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
-- The linear abstract machine | |
-- as described in the "The Linear Abstract Machine" | |
-- Environment is a representation of a canonical combinator | |
-- the canonical combinator u ⊗ v is represented by Ja, and 1 by Nil | |
-- the canonical combinator y ∘ v represented by Comb: y is piece of code. | |
-- | |
-- Code is list of primitive instructions. | |
-- | |
-- Sequential composition becomes concatenation (in opposite order), |