Skip to content

Instantly share code, notes, and snippets.

@apskii
apskii / Bounce
Last active August 29, 2015 14:13
Bounce
// run here: http://jsfiddle.net/6mt3ffpe/
module Bounce where
import DOM
import Graphics.Canvas
import Control.Monad.Eff
import Control.Monad.Eff.Ref
import Control.Monad.Trans
import Control.Monad.RWS
@apskii
apskii / SRT.scala
Created November 22, 2014 01:24
Subtyping recursive types
sealed trait Type {
override def equals(y: Any) = super.equals(y)
override def hashCode = super.hashCode
def isSubtypeOf(ty: Type): Boolean = {
def f(a: Type, b: Type, trail: Set[(Any, Any)]): Boolean =
if (trail contains (a, b))
true
else (a, b) match {
case (Bot, _) => true
import scala.collection.immutable
sealed trait SP[-A, +B] {
def run(input: Stream[A]): Stream[B] = this match {
case Put(value, sp) => value #:: sp.run(input)
case Get(builder) => input match {
case x #:: xs => builder(x).run(xs)
case _ => Stream.empty
}
}
{-# LANGUAGE RankNTypes, TypeFamilies, RecordWildCards, GADTs, KindSignatures #-}
module Main where
import Data.List as L
import Data.Vector as V
import Data.Vector.Unboxed as U
import Data.Foldable as F
type family Observation c :: *
type instance Observation () = [Float]
import scala.collection._
class Bag[E] private (val items: Map[E, Int]) {
def isEmpty = items.isEmpty
def view = items.keys.view
def -(item: E) = new Bag[E](items(item) match {
case 1 => items - item
case n => items.updated(item, n - 1)
})
}
#!/usr/bin/env python3.4
import sys
import asyncio as aio
import concurrent.futures as cf
from getpass import getpass
from itertools import takewhile
import github3
// utils.js
(function ($,sr) {
var debounce = function (func, threshold, execAsap) {
var timeout;
return function debounced () {
var obj = this, args = arguments;
function delayed () {
if (!execAsap)
func.apply(obj, args);
package apsk.jpatmat;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.function.Consumer;
import java.util.function.Function;
public class Entry {
// Simple Arithmetic Language
(defmacro $ (&rest rest) `(funcall ,@rest))
(defstruct builder
combine
bind
return
return-from
yield
yield-from
using
(defmacro monadic (&body statements)
`(let ((m *monad*))
(statements-of (monad m) ,@statements)))
(defun monad-example (ma mb)
(monadic
(get x ma)
(get y mb)
(val z (+ x y))
(ret (list x y z))))