Skip to content

Instantly share code, notes, and snippets.

View zen0wu's full-sized avatar
⌨️
Smashing Keyboard

Zeno Wu zen0wu

⌨️
Smashing Keyboard
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:

@hallettj
hallettj / adt.js
Last active March 4, 2024 07:05
Sealed algebraic data type (ADT) in Javascript with Flow
/* @flow */
// Helper function for matching against an ADT.
export function match<A,B>(matcher: A): (match: (matcher: A) => B) => B {
return match => match(matcher)
}
@MohamedAlaa
MohamedAlaa / tmux-cheatsheet.markdown
Last active May 7, 2024 06:03
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@whiter4bbit
whiter4bbit / gist:2011424
Created March 10, 2012 13:31
Dijkstra using scalding
import com.twitter.scalding._
class DijkstraJob(args: Args) extends Job(args) {
val iteration = args.getOrElse("iteration", "0").toInt
Tsv(args("input"), ('node, 'dist, 'adjacent))
.read
.flatMap(('node, 'dist, 'adjacent) -> ('node, 'dist, 'adjacent)) { p: (String, Int, String) =>
val (node, distance, adjacent) = p
(node, distance, adjacent) +: adjacent.split(":").map { part: String =>
@dnagir
dnagir / rspec-syntax-cheat-sheet.rb
Created November 5, 2010 09:29
RSpec 2 syntax cheat sheet by example
# RSpec 2.0 syntax Cheet Sheet by http://ApproachE.com
# defining spec within a module will automatically pick Player::MovieList as a 'subject' (see below)
module Player
describe MovieList, "with optional description" do
it "is pending example, so that you can write ones quickly"
it "is already working example that we want to suspend from failing temporarily" do
pending("working on another feature that temporarily breaks this one")