Skip to content

Instantly share code, notes, and snippets.

@jliszka
jliszka / gist:2880013
Created June 6, 2012 04:55
Multiple phantom types in a single type parameter
object test {
sealed trait Limited
sealed trait Unlimited
sealed trait Lim extends Limited with Unlimited
sealed trait Skipped
sealed trait Unskipped
sealed trait Sk extends Skipped with Unskipped
@ckirkendall
ckirkendall / clojure-match.clj
Created June 15, 2012 02:26 — forked from bkyrlach/Expression.fs
Language Compare F#, Ocaml, Scala, Clojure, Ruby and Haskell - Simple AST example
(use '[clojure.core.match :only [match]])
(defn evaluate [env [sym x y]]
(match [sym]
['Number] x
['Add] (+ (evaluate env x) (evaluate env y))
['Multiply] (* (evaluate env x) (evaluate env y))
['Variable] (env x)))
(def environment {"a" 3, "b" 4, "c" 5})
@larsrh
larsrh / nameplicitly.scala
Created July 3, 2012 12:29
Attempting a by-name implicitly
import language.experimental.macros
import scala.reflect.makro.Context
object Name {
def nameplicitly[T](implicit t0: T): Name[T] = macro nameplicitly_impl[T]
def nameplicitly_impl[T : c.TypeTag](c: Context)(t0: c.Expr[T]): c.Expr[Name[T]] =
c.reify(new Name[T] { def t = t0.splice })
@harshithjvmi
harshithjvmi / github-code-view-expander.js
Created October 17, 2012 06:55
Github code view expander
$("#js-repo-pjax-container, .frames > .frame-center").width($(document.body).width()-20);
@seanparsons
seanparsons / gist:3928225
Created October 21, 2012 19:46
Expanded inventory example using Semigroups.
scala> import scalaz._
import scalaz._
scala> import Scalaz._
import Scalaz._
scala> :paste
// Entering paste mode (ctrl-D to finish)
sealed abstract class Inventory
@patriknw
patriknw / PeekMailbox.scala
Created November 21, 2012 14:20
PeekMailbox example
package example
import java.util.concurrent.ConcurrentHashMap
import java.util.concurrent.ConcurrentLinkedQueue
import com.typesafe.config.Config
import com.typesafe.config.ConfigFactory
import akka.actor.Actor
import akka.actor.ActorContext
import akka.actor.ActorRef
import akka.actor.ActorSystem
(ns net.cgrand.decay
"Exponentially decaying lists. See http://awelonblue.wordpress.com/2013/01/24/exponential-decay-of-history-improved/
for background and http://clj-me.cgrand.net/2013/02/12/decaying-lists-log-scale-for-lists/ for documentation")
;; PRNG, formulas straight from java.util.Random javadoc
(defn- seed ^long [^long n]
(bit-and (unchecked-multiply n 0x5DEECE66D)
(unchecked-dec (bit-shift-left 1 48))))
(defn- next-seed ^long [^long seed]
@quchen
quchen / trolling_haskell
Last active November 12, 2024 00:10
Trolling #haskell
13:15 <xQuasar> | HASKELL IS FOR FUCKIN FAGGOTS. YOU'RE ALL A BUNCH OF
| FUCKIN PUSSIES
13:15 <xQuasar> | JAVASCRIPT FOR LIFE FAGS
13:16 <luite> | hello
13:16 <ChongLi> | somebody has a mental illness!
13:16 <merijn> | Wow...I suddenly see the error of my ways and feel
| compelled to write Node.js!
13:16 <genisage> | hi
13:16 <luite> | you might be pleased to learn that you can compile
| haskell to javascript now
anonymous
anonymous / gist:5375768
Created April 12, 2013 22:39
00:17:34 <retronym> trepidacious_: comonad/costate isn't really neccessary for lenses. try this presentation: http://www.youtube.com/watch?v=efv0SQNde5Q
00:18:03 ? nomadmonad and milessabin quit
00:18:07 <edwardk> hey that looks familiar
00:18:38 ? jesnor ([email protected]) quit: Ping timeout: 240 seconds
00:20:52 <gseitz> shouldn't costate just be an implementation detail
00:20:53 <gseitz> ?
00:21:04 ? pantsman and j0ran quit
00:21:24 <larsrh> edwardk: are you aware of an introductory paper about comonads?
00:21:43 <edwardk> not really. i gave a talk on them at the first boston haskell i should have some slides handy
00:21:46 ? vsayer ([email protected]) quit: Ping timeout: 244 seconds
@bitemyapp
bitemyapp / gist:8739525
Last active May 7, 2021 23:22
Learning Haskell