Skip to content

Instantly share code, notes, and snippets.


Melchizedek Mzk-Levi

View GitHub Profile
runarorama / gist:33986541f0f1ddf4a3c7
Created May 7, 2015
Higher-kinded types encoded as path-dependent types
View gist:33986541f0f1ddf4a3c7
trait λ {
type α
trait Functor extends λ {
type α <: λ
def map[A,B](x: α { type α = A })(f: A => B): α { type α = B }
conal / NatStream.hs
Last active Aug 29, 2015
Isomorphism between streams and function-of-Nat
View NatStream.hs
{-# OPTIONS_GHC -Wall #-}
module NatStream where
data Nat = Zero | Succ Nat
data Stream a = a :< Stream a
-- Stream is the trie induced by Nat.
-- Here's the isomorphism, explicitly:
djspiewak /
Created Mar 22, 2015
Introduction to scalaz-stream

Introduction to scalaz-stream

Every application ever written can be viewed as some sort of transformation on data. Data can come from different sources, such as a network or a file or user input or the Large Hadron Collider. It can come from many sources all at once to be merged and aggregated in interesting ways, and it can be produced into many different output sinks, such as a network or files or graphical user interfaces. You might produce your output all at once, as a big data dump at the end of the world (right before your program shuts down), or you might produce it more incrementally. Every application fits into this model.

The scalaz-stream project is an attempt to make it easy to construct, test and scale programs that fit within this model (which is to say, everything). It does this by providing an abstraction around a "stream" of data, which is really just this notion of some number of data being sequentially pulled out of some unspecified data source. On top of this abstraction, sca

paf31 /
Last active May 17, 2020
Reimplementing a NodeJS Service in Haskell


At DICOM Grid, we recently made the decision to use Haskell for some of our newer projects, mostly small, independent web services. This isn't the first time I've had the opportunity to use Haskell at work - I had previously used Haskell to write tools to automate some processes like generation of documentation for TypeScript code - but this is the first time we will be deploying Haskell code into production.

Over the past few months, I have been working on two Haskell services:

  • A reimplementation of an existing service, previously written for NodeJS using TypeScript.
  • A new service, which would interact with third-party components using standard data formats from the medical industry.

I will write here mostly about the first project, since it is a self-contained project which provides a good example of the power of Haskell. Moreover, the proces

pchiusano / machines.hs
Last active Aug 29, 2015
Design of new basis for machines / scalaz-stream that does not require separate plan type
View machines.hs
-- Type-aligned sequence catenable queue supporting O(1) append, snoc, uncons
-- Don't need it to be a dequeue (unsnoc not needed)
data TCQueue c a b -- c is the category, a is starting type, b is ending type
type Channel f a b = TCQueue (Transition f) a b
type Process f b = Channel f () b
data Transition f a b where
Bind :: (a -> Process f b) -> Transition f a b
OnHalt :: (Cause -> Process f b) -> Transition f a b
pchiusano / type-inhabitants.markdown
Last active Jan 21, 2020
Reasoning about type inhabitants in Haskell
View type-inhabitants.markdown

This is material to go along with a 2014 Boston Haskell talk.

We are going to look at a series of type signatures in Haskell and explore how parametricity (or lack thereof) lets us constrain what a function is allowed to do.

Let's start with a decidedly non-generic function signature. What are the possible implementations of this function which typecheck?

wrangle :: Int -> Int
EECOLOR / 0_Program.scala
Last active Apr 17, 2017
Wrapper for Free monads that (at least I thought) makes them more usable. Different languages can be composed at will (without manual lifting). Runners should have all the used types in the composed program, but they do not have to be in the same order.
View 0_Program.scala
package test
import scala.language.higherKinds
case class Program[F[_], A](free: Free[F, A]) {
import Coproduct.|
def flatMap[G[_], B](f: A => Program[G, B])(
implicit c: F | G): Program[c.Out, B] =
staltz /
Last active Jan 17, 2021
The introduction to Reactive Programming you've been missing
kevinwright /
Last active Mar 8, 2018
Scaladays 2014 slides

As compiled by Kevin Wright a.k.a @thecoda

(executive producer of the movie, and I didn't even know it... clever huh?)

please, please, please - If you know of any slides/code/whatever not on here, then ping me on twitter or comment this Gist!

This gist will be updated as and when I find new information. So it's probably best not to fork it, or you'll miss the updates!

Monday June 16th

View FreeT.hs
{-# LANGUAGE RankNTypes #-}
import Prelude hiding (readFile)
import qualified Prelude as P
data Free f a =
Done a
| More (f (Free f a))
instance Functor f => Functor (Free f) where
You can’t perform that action at this time.