Skip to content

Instantly share code, notes, and snippets.

View diab0l's full-sized avatar

Marian Stramm diab0l

  • Dr. Ecklebe GmbH
  • Berlin, Germany
View GitHub Profile
// Stuff needed to make C# a kind of cluttered subtyping Haskell:
// - Higher kinded polymorphism (being able to pass Generic Type Definitions as type parameters)
// - Static interfaces & static abstract types (this gets quite perverse at the CLR level)
// - GADTS (easily implemented as syntactic sugar)
namespace HKP {
public static A<B> Create<A, B>() where A : <>, new() {
return new A<B>(); // Can't do a whole lot of useful things here, since we know little about TFn
}
const int KeysMax = 1024 * 1024; // 1MB
const int ValueLength = 4096; // 4KB
// using a jagged array. Note that the same arguments apply to algebraic arrays, though they are not as severe
byte[][] goodLut = new byte[KeysMax][];
for(int i = 0; i < KeysMax; i++) {
goodLut[i] = new int[ValueLength];
}
byte[][] badLut = new byte[ValueLength][];