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 / FAlg.ml
Created Feb 16, 2015
More F-algebra things in OCaml
View FAlg.ml
module type Functor = sig
type 'a t
val map : ('a -> 'b) -> ('a t -> 'b t)
end
module Iso = struct
type ('a, 'b) t = { fwd : 'a -> 'b; bck : 'b -> 'a }
let fwd i = i.fwd
let bck i = i.bck
@tel
tel / ParserCombinators.hs
Created Nov 3, 2014
Monad transformers and parser combinators
View ParserCombinators.hs
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
module ParserCombinators where
{-
We'll build a set of parser combinators from scratch demonstrating how
they arise as a monad transformer stack. Actually, how they arise as a
choice between two different monad transformer stacks!
@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 / 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 / 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);
@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 / PipeLog.hs
Last active Jan 13, 2018
Pipes-based logger
View PipeLog.hs
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
module PipeLog where
import Control.Applicative
import Data.Functor.Identity
import Pipes
import qualified Pipes.Prelude as P
newtype LogT l m a =
@tel
tel / Lenses.scala
Created Apr 18, 2017
Pure profunctor lenses in Scala
View Lenses.scala
import scala.language.higherKinds
object Lenses {
trait Profunctor[P[_, _]] {
def dimap[A, B, C, D](f: C => A, g: B => D)(p: P[A, B]): P[C, D]
}
object Profunctor {
View Rel.idr
module Rel
DecProofType : {a:Type} -> Dec a -> Type
DecProofType {a} (Yes _) = a
DecProofType {a} (No _) = a -> _|_
decProof : {a:Type} -> (dec : Dec a) -> DecProofType dec
decProof (Yes x) = x
decProof (No x) = x
View AssocIn.hs
{-# LANGUAGE GADTs #-}
module Lib where
import qualified Data.HashMap.Lazy as M
import Data.Hashable
import Data.Typeable
-- this is what we know about all things from Java
data Val where
You can’t perform that action at this time.