Skip to content

Instantly share code, notes, and snippets.

View relrod's full-sized avatar

Rick Elrod relrod

View GitHub Profile
@puffnfresh
puffnfresh / lenz-readme.md
Created February 18, 2014 01:25
Scala Lenz README

Scala Lenz

This library is a port of Haskell's lens. The goal is to provide functional lenses, isomorphisms, getters and setters.

Examples

Isomorphisms

@relrod
relrod / gist:9505572
Last active August 29, 2015 13:57
Lens dependencies for Fedora
Unpackaged ghc-lens deps:
BuildRequires: ghc-bifunctors-devel #
BuildRequires: ghc-comonad-devel #
BuildRequires: ghc-contravariant-devel #1075598
BuildRequires: ghc-distributive-devel #1075605
BuildRequires: ghc-exceptions-devel #1075601
BuildRequires: ghc-profunctors-devel #
BuildRequires: ghc-reflection-devel #1076737
@rossdylan
rossdylan / fedmsg.hs
Created July 12, 2014 00:04
simple fedmsg haskell thingy
module Main where
import System.ZMQ
import Control.Monad (replicateM, forever)
import qualified Data.ByteString
import Text.Printf
type Topics = [String]
type MessageHandler = (Data.ByteString.ByteString -> IO ())
subscribeTopics :: SubsType a => Topics -> Socket a -> IO ()
@rampion
rampion / SO25210743.hs
Last active August 29, 2015 14:05
Solution for [Bicategories in Haskell](http://stackoverflow.com/questions/25210743/bicategories-in-haskell) on StackOverflow
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE ScopedTypeVariables #-}
@mattdeboard
mattdeboard / spotify.el
Created August 6, 2011 23:05
Small minor mode to control spotify from emacs
;;Small minor mode to control spotify from emacs
(defun spotify-play () "Play Spotify" (interactive)
(shell-command "dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Play"))
(defun spotify-pause () "Pause Spotify" (interactive)
(shell-command "dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Pause"))
(defun spotify-playpause () "Play/Pause Spotify" (interactive)
(shell-command "dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.PlayPause"))
@jestan
jestan / gist:3692077
Created September 10, 2012 16:51 — forked from mtnygard/gist:2254147
Books I recommended today
@ekmett
ekmett / Golf.hs
Created November 2, 2012 23:58
golfing pi and e
-- e
> let z a b c d w@(x:y)=let t=a`div`c in if all(>0)[a,b,c,d]&&t==b`div`d then t:z(10*(a-c*t))(10*(b-d*t))c d w else z(x*a+b)a(x*c+d)c y;f n=1:1:n:f(n+2)in z 1 0 0 1(2:1:2:f 4)>>=show
> let z a b c d w@(x:y)|t<-a`div`c=if all(>0)[a,b,c,d]&&t==b`div`d then t:z(10*(a-c*t))(10*(b-d*t))c d w else z(x*a+b)a(x*c+d)c y;f n=1:1:n:f(n+2)in z 1 0 0 1(2:1:2:f 4)>>=show
> let z a b c d w@(x:y)|all(>0)[a,b,c,d]&&t==b`div`d|True=t:z(10*(a-c*t))(10*(b-d*t))c d w else z(x*a+b)a(x*c+d)c y where t=a`div`c;f n=1:1:n:f(n+2)in z 1 0 0 1(2:1:2:f 4)>>=show
> let z a b c d w@(x:y)|all(>0)[a,b,c,d]&&t==b`div`d=t:z(10*(a-c*t))(10*(b-d*t))c d w|True=z(x*a+b)a(x*c+d)c y where{t=a`div`c};f n=1:1:n:f(n+2)in z 1 0 0 1(2:1:2:f 4)>>=show
> let f n=1:1:n:f(n+2);z a b c d w@(x:y)|t<-a`div`c,all(>0)[a,b,c,d]&&t==b`div`d=t:z(10*(a-c*t))(10*(b-d*t))c d w|True=z(x*a+b)a(x*c+d)c y in z 1 0 0 1(2:1:2:f 4)>>=show
> let f n=1:1:n:f(n+2);z a b c d w@(x:y)|any(<=0)[a,b,c,d]||t/=b`div`d=z(x*a+b)a(x*c+d)c y|t<-a`div`c=t:z(10*(a-c*t))(10*(b-d*t))c d w
@mxswd
mxswd / Monad.cc
Last active December 28, 2015 07:49
#include <tr1/type_traits>
#include <iostream>
#include <vector>
#include <algorithm>
// (* -> *) -> Constraint
template<template <typename> class T>
class Functor {
public:
template <typename A, typename B>
@tonymorris
tonymorris / scalaz.scala
Created January 5, 2014 01:16
Questions about \/ and Validation
// Questions about \/ and Validation
object scalaz {
/*
This explanation might help. This is a compilable source file with revisions
available at https://gist.github.com/tonymorris/8263051
Fact: All monads are applicative functors. As has been seen we can witness the
`Applicative` that arises from the `Monad` primitives. Let's illustrate this: