Skip to content

Instantly share code, notes, and snippets.

View miketang84's full-sized avatar
🏠
Working from home

Mike Tang miketang84

🏠
Working from home
  • Vancouver
View GitHub Profile
@edmundsmith
edmundsmith / writeup.md
Created July 7, 2019 20:47
Method for Emulating Higher-Kinded Types in Rust

Method for Emulating Higher-Kinded Types in Rust

Intro

I've been fiddling about with an idea lately, looking at how higher-kinded types can be represented in such a way that we can reason with them in Rust here and now, without having to wait a couple years for what would be a significant change to the language and compiler.

There have been multiple discussions on introducing higher-ranked polymorphism into Rust, using Haskell-style Higher-Kinded Types (HKTs) or Scala-looking Generalised Associated Types (GATs). The benefit of higher-ranked polymorphism is to allow higher-level, richer abstractions and pattern expression than just the rank-1 polymorphism we have today.

As an example, currently we can express this type:

@karpathy
karpathy / min-char-rnn.py
Last active November 18, 2024 15:04
Minimal character-level language model with a Vanilla Recurrent Neural Network, in Python/numpy
"""
Minimal character-level Vanilla RNN model. Written by Andrej Karpathy (@karpathy)
BSD License
"""
import numpy as np
# data I/O
data = open('input.txt', 'r').read() # should be simple plain text file
chars = list(set(data))
data_size, vocab_size = len(data), len(chars)
@dradtke
dradtke / lib.rs
Last active August 29, 2015 14:07
An experiment in designing a turn-based concurrent game architecture.
//! Source file for the `game` crate.
#![allow(dead_code)]
/// The `Player` trait.
pub trait Player {
/// Gets called when it's time for this player to take their turn.
///
/// The game is played by sending commands on `pipe` and checking
/// the responses that are returned.
fn take_turn(&self, pipe: &PlayerActionPipe, round: uint);