Skip to content

Instantly share code, notes, and snippets.

✍️

Joseph Abrahamson tel

✍️
Block or report user

Report or block tel

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@tel
tel / Hf.scala
Created Jun 14, 2016
Higher-order free constructions in Scala
View Hf.scala
import scala.language.higherKinds
trait Tc1 {
type T[_]
}
trait Functor extends Tc1 {
def map[A, B](f: A => B)(ta: T[A]): T[B]
}
@tel
tel / AbstractModel.scala
Created Mar 14, 2016
Beautiful "Graphs" signature example from Martin Odersky's "Scala: The Simple Parts"
View AbstractModel.scala
/**
* Partially (!) specializes Graphs signature.
*
* Note that Node and Edge are still abstract! We add new
* functionality by concretely specifying Graph, but the DSL
* still works in its limited initial form since newGraph abstracted
* over Graph construction
*
*/
@tel
tel / Elm.scala
Created Mar 3, 2016
Scala.js Elm-alike
View Elm.scala
package tutorial.webapp
import japgolly.scalajs.react._
import japgolly.scalajs.react.vdom.prefix_<^._
import org.scalajs.dom
import scala.scalajs.js.JSApp
trait Component {
type Params
@tel
tel / Corec.hs
Created Jan 30, 2016
Constraints and Corecords
View Corec.hs
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
@tel
tel / Sums.js
Created Aug 4, 2015
Sums in Javascript
View Sums.js
/*
"Concrete" sums are by default open. They are values of the form
{ variant: String, params: {[String]: *} }
*/
/**
@tel
tel / Rou.hs
Created Jul 26, 2015
Rou(ting)
View Rou.hs
{-# LANGUAGE TypeOperators, TupleSections, LambdaCase, RecordWildCards, RankNTypes #-}
module Rou where
import Control.Lens
import Data.Map (Map)
import qualified Data.Map as Map
import Data.Monoid
import Control.Monad
import Control.Applicative
@tel
tel / ProfunctorLens.js
Last active Apr 3, 2019
Pure Profunctor Lenses in Javascript (redux)
View ProfunctorLens.js
/* eslint-disable new-cap */
/**
* Lens types.
* ===========
*
* a * b = {fst: a, snd: b}
* a + b = {index: Boolean, value: a | b}
*
* Iso s t a b = forall (~>) . Profunctor (~>) => (a ~> b) -> (s ~> t)
@tel
tel / Profunctor.js
Last active Apr 3, 2019
"Pure-profunctor" lenses in Javascript (!)
View Profunctor.js
/// PRELIMINARIES
/**
* Generalized "products" of any size. For gluing things together. A tuple is a
* "2"-meet.
*
* The type `Meet a b c d ...` indicates a `Meet` of the given size with values
* at each type in the sequence.
*/
@tel
tel / Lens.js
Created Jun 20, 2015
Really simple van Laarhoven lenses in Javascript
View Lens.js
const IdModule = {
fmap: (fn) => (x) => fn(x),
}
const ConstModule = {
fmap: (fn) => (x) => x,
}
/**
@tel
tel / Cont.js
Created Jun 4, 2015
Continuation monad in Javascript
View Cont.js
function Cont(contHandler) {
this.contHandler = contHandler;
};
Cont.unit = function(value) {
return new Cont(function (continue) { return continue(value); });
};
Cont.prototype.run = function(resume) {
return this.contHandler(resume);
You can’t perform that action at this time.