Skip to content

Instantly share code, notes, and snippets.

View Mzk-Levi's full-sized avatar

Melchizedek Mzk-Levi

View GitHub Profile
@runarorama
runarorama / gist:33986541f0f1ddf4a3c7
Created May 7, 2015 14:06
Higher-kinded types encoded as path-dependent types
trait λ {
type α
}
trait Functor extends λ {
type α <: λ
def map[A,B](x: α { type α = A })(f: A => B): α { type α = B }
}
@kevinwright
kevinwright / scaladays2014.md
Last active March 8, 2018 20:25
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

@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
@HeinrichApfelmus
HeinrichApfelmus / gist:2187593
Created March 24, 2012 20:42
BIjection between Twan van Laarhoven's Pipe and the data types from Conduit
-- http://www.reddit.com/r/haskell/comments/rbgvz/conduits_vs_pipes_using_void_as_an_input_or/
import Control.Monad
data Pipe m i o r =
NeedInput (i -> Pipe m i o r) (Pipe m () o r)
| HaveOutput (Pipe m i o r) (m ()) o
| Finished (Maybe i) r
| PipeM (m (Pipe m i o r)) (m r)
@EECOLOR
EECOLOR / 0_Program.scala
Last active April 17, 2017 11:13
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.
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] =
@tonymorris
tonymorris / Terminal.hs
Created May 22, 2014 09:04
Terminal I/O with Free
{-# LANGUAGE RankNTypes #-}
data Free f a =
Done a
| More (f (Free f a))
instance Functor f => Functor (Free f) where
fmap f (Done a) =
Done (f a)
fmap f (More k) =
@raichoo
raichoo / gist:5371927
Last active May 12, 2016 18:43
Playing with propositional equality in Scala (+inductive proof)
import scala.language.higherKinds
/*
* The usual peano numbers with addtion and multiplication
*/
sealed trait Nat {
type Plus[N <: Nat] <: Nat
type Mult[N <: Nat] <: Nat
}

Reasoning

  • observations lead to conclusions
  • conclusions, based on observations, lead to new conclusions
  • conclusions do not lead to themselves
  • conclusions do not lead to observations

You might suspect something to be true (a conclusion). You question why you believe it to be true -- hypothesis formation. When you fail to find reasons to believe it to be true, you abandon the hypothesis. It could be that:

package com.nicta
package jdbc
import java.sql.SQLException
import scalaz._, Scalaz._
// 1 + A
sealed trait ?[A] {
import ?._