Skip to content

Instantly share code, notes, and snippets.

View dylech30th's full-sized avatar
🥲
Mais il me reste, ce que vous ne voyez pas.

Dylech30th dylech30th

🥲
Mais il me reste, ce que vous ne voyez pas.
View GitHub Profile
@dylech30th
dylech30th / SystemFSub.cs
Last active October 2, 2022 00:42
A SystemF<: (Bounded Quantification) implementation in C#, along with some simple extensions including union type, intersection type, condition, and general recursion through fixed-point combinator
// ReSharper disable MemberCanBePrivate.Global
// ReSharper disable UnusedType.Global
// ReSharper disable ClassNeverInstantiated.Global
// ReSharper disable ParameterTypeCanBeEnumerable.Local
// ReSharper disable ReturnTypeCanBeEnumerable.Local
using System.Diagnostics;
using System.Text;
namespace SystemFSub;
@dylech30th
dylech30th / SystemF.fs
Last active September 27, 2022 13:49
A typechecker for SystemF (without existential type), uses α-conversion to perform capture-free subtitution
type SystemFType =
| TVariable of name : string
| TArrow of domain : SystemFType * result : SystemFType
| TUniversal of binder : string * body : SystemFType
override this.ToString() =
let rec aux = function
| TVariable name -> name
| TArrow (domain, result) ->
match domain with
@dylech30th
dylech30th / Unification.scala
Last active July 12, 2023 20:48
The implementation of unification-based type inference algorithm in pure simply typed lambda calculus with Let Polymorphism
/**
* The implementation of unification-based type inference algorithm in simply typed lambda calculus with Let-Polymorphism
*
* The unification-based type inference algorithm is widely used in a huge variety of programming languages, where the most
* famous one is the Hindley-Milner Type System (a.k.a Damas-Milner Type System) of the ML-Family which permits the programmer
* to omit almost all of the type annotations, the algorithm is based on two concepts: Constraint Set and Unifier.
*
* A constraint set consist of several constraints, a constraints is basically a type equation, e.g., X = T, where both X and
* T are types
* A unifier is a set of type substitutions [X -> T1, Y -> T2, ...], it replaces all the type variables in its domain to the
package ink.sora.ioc
import java.io.Closeable
import java.lang.IllegalArgumentException
import kotlin.random.Random
import kotlin.reflect.*
import kotlin.reflect.full.declaredMemberProperties
import kotlin.reflect.full.hasAnnotation
import kotlin.reflect.full.isSubclassOf
import kotlin.reflect.full.primaryConstructor
@dylech30th
dylech30th / Collections.cs
Last active May 29, 2021 14:21
Dragon book chapter 3 code
using System.Collections;
using System.Collections.Generic;
namespace CompilerExercise
{
public static class Collections
{
public static int IntArrayHash(this int[] array)
{
return StructuralComparisons.StructuralEqualityComparer.GetHashCode(array);
@dylech30th
dylech30th / gist:2d59553b6641c4493370f8ec731aa38f
Created November 7, 2019 12:39
OHHHHHHHHHHHHHHHHHHHHHHINHUMANREACTION
00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
64 38 3A 61 6E 6E 6F 75 6E 63 65 33 37 3A 68 74
74 70 3A 2F 2F 65 68 74 72 61 63 6B 65 72 2E 6F
72 67 2F 31 32 31 34 37 37 38 2F 61 6E 6E 6F 75
6E 63 65 37 3A 63 6F 6D 6D 65 6E 74 37 33 3A 20
3A 3A 20 54 6F 72 72 65 6E 74 20 64 6F 77 6E 6C
6F 61 64 65 64 20 66 72 6F 6D 20 45 2D 48 65 6E
74 61 69 20 47 61 6C 6C 65 72 69 65 73 20 2D 20
68 74 74 70 73 3A 2F 2F 65 2D 68 65 6E 74 61 69
2E 6F 72 67 2F 20 3A 3A 31 30 3A 63 72 65 61 74