Skip to content

Instantly share code, notes, and snippets.

View relrod's full-sized avatar

Rick Elrod relrod

View GitHub Profile
@t0yv0
t0yv0 / subtyping.v
Last active February 28, 2021 01:47
Demonstrating TypeScript 0.8 type system to be unsound. The subtyping relationship is defined in a way that admits the following code that results in TypeError exception being thrown.
Require Import Utf8.
Inductive subtype (a b : Set) : Set :=
| ST : (a -> b) -> subtype a b.
Infix ":>" := subtype (at level 50).
Definition st {x y} f := ST x y f.
Definition unpack {a b : Set} (st : a :> b) :=
@ymasory
ymasory / scala-irc
Last active August 30, 2017 21:16
List of all Scala-related IRC channels.
Please help compile a list of all Scala-related IRC rooms.
All of these channels are on Freenode.
#akka | concurrency & distribution framework
#argonaut | json library
#fp-in-scala | the book Functional Programming in Scala
#geotrellis | geoprocessing library
#indyscala | regional scala group
#json4s | json library
@ekmett
ekmett / Golf.hs
Created November 2, 2012 23:58
golfing pi and e
-- e
> let z a b c d w@(x:y)=let t=a`div`c in if all(>0)[a,b,c,d]&&t==b`div`d then t:z(10*(a-c*t))(10*(b-d*t))c d w else z(x*a+b)a(x*c+d)c y;f n=1:1:n:f(n+2)in z 1 0 0 1(2:1:2:f 4)>>=show
> let z a b c d w@(x:y)|t<-a`div`c=if all(>0)[a,b,c,d]&&t==b`div`d then t:z(10*(a-c*t))(10*(b-d*t))c d w else z(x*a+b)a(x*c+d)c y;f n=1:1:n:f(n+2)in z 1 0 0 1(2:1:2:f 4)>>=show
> let z a b c d w@(x:y)|all(>0)[a,b,c,d]&&t==b`div`d|True=t:z(10*(a-c*t))(10*(b-d*t))c d w else z(x*a+b)a(x*c+d)c y where t=a`div`c;f n=1:1:n:f(n+2)in z 1 0 0 1(2:1:2:f 4)>>=show
> let z a b c d w@(x:y)|all(>0)[a,b,c,d]&&t==b`div`d=t:z(10*(a-c*t))(10*(b-d*t))c d w|True=z(x*a+b)a(x*c+d)c y where{t=a`div`c};f n=1:1:n:f(n+2)in z 1 0 0 1(2:1:2:f 4)>>=show
> let f n=1:1:n:f(n+2);z a b c d w@(x:y)|t<-a`div`c,all(>0)[a,b,c,d]&&t==b`div`d=t:z(10*(a-c*t))(10*(b-d*t))c d w|True=z(x*a+b)a(x*c+d)c y in z 1 0 0 1(2:1:2:f 4)>>=show
> let f n=1:1:n:f(n+2);z a b c d w@(x:y)|any(<=0)[a,b,c,d]||t/=b`div`d=z(x*a+b)a(x*c+d)c y|t<-a`div`c=t:z(10*(a-c*t))(10*(b-d*t))c d w
@puffnfresh
puffnfresh / covariant.ts
Created October 1, 2012 17:06
Covariant arrays. Blurgh.
// Compiles fine even though the code is broken.
// This is because arrays are covariant and mutable.
//
// TypeScript team: Please fix either of those things. Preferably mutability :)
class Animal {}
class Snake extends Animal {
slither() {
alert("Slithering!")
@jestan
jestan / gist:3692077
Created September 10, 2012 16:51 — forked from mtnygard/gist:2254147
Books I recommended today
@tonymorris
tonymorris / Lens.cs
Created August 5, 2012 05:43
Lens library for C# (demonstration)
using System;
using System.Collections;
using System.Collections.Generic;
/*
A basic lens library for the purpose of demonstration.
Implements a lens as the costate comonad coalgebra.
This library is not complete.
A more complete lens library would take from
@judofyr
judofyr / fizzbuzz.rb
Created August 1, 2012 21:37 — forked from JEG2/fizzbuzz.rb
Writing FizzBuzz with flip-flops
a=b=c=(1..100).each do |num|
print num, ?\r,
("Fizz" unless (a = !a) .. (a = !a)),
("Buzz" unless (b = !b) ... !((c = !c) .. (c = !c))),
?\n
end
@minosiants
minosiants / gist:3163791
Created July 23, 2012 14:06
Akka EventBus simple example
package com.minosiants
import akka.event.ActorEventBus
import akka.event.LookupClassification
import akka.actor.ActorSystem
import akka.actor.Props
import akka.actor.Actor
import java.util.Date
import java.util.UUID
@ckirkendall
ckirkendall / clojure-match.clj
Created June 15, 2012 02:26 — forked from bkyrlach/Expression.fs
Language Compare F#, Ocaml, Scala, Clojure, Ruby and Haskell - Simple AST example
(use '[clojure.core.match :only [match]])
(defn evaluate [env [sym x y]]
(match [sym]
['Number] x
['Add] (+ (evaluate env x) (evaluate env y))
['Multiply] (* (evaluate env x) (evaluate env y))
['Variable] (env x)))
(def environment {"a" 3, "b" 4, "c" 5})
@guillaumebort
guillaumebort / 1.sql
Created May 25, 2012 15:17
Play 2.0/Anorm
# --- !Ups
CREATE TABLE users(
email VARCHAR(255) NOT NULL PRIMARY KEY,
name VARCHAR(255)
);
CREATE TABLE subjects(
id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,
title LONGTEXT NOT NULL,