Skip to content

Instantly share code, notes, and snippets.

View jroesch's full-sized avatar

Jared Roesch jroesch

View GitHub Profile
Resolving dependencies...
Notice: installing into a sandbox located at
/Users/jroesch/OpenSource/sparse/.cabal-sandbox
Downloading dlist-0.6.0.1...
Configuring nats-0.1.2...
Configuring newtype-0.2...
Configuring parallel-3.2.0.4...
Configuring primitive-0.5.1.0...
Configuring tagged-0.7...
Configuring split-0.2.2...
@jroesch
jroesch / gist:9358764
Last active August 29, 2015 13:57
while loops are just tail recursion LOLOL!
Welcome to Scala version 2.10.3 (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0_21).
Type in expressions to have them evaluated.
Type :help for more information.
scala> :power
** Power User mode enabled - BEEP WHIR GYVE **
** :phase has been set to 'typer'. **
** scala.tools.nsc._ has been imported **
** global._, definitions._ also imported **
** Try :help, :vals, power.<tab> **
@jroesch
jroesch / SimpleLens.hs
Last active August 29, 2015 13:57
A simple lens presentation, saving for posterities sake.
{-# LANGUAGE RankNTypes #-}
module SimpleLens where
import Data.Functor.Identity
import Data.Functor.Constant
type LensP s t a b = forall f. Functor f => (a -> f b) -> s -> f t
type Lens s a = LensP s s a a
@jroesch
jroesch / IdExample.hs
Created March 30, 2014 04:40
Simple RankNTypes example
{-# LANGUAGE RankNTypes #-}
module IdExamples where
vanilla :: (a -> a) -> a -> a
vanilla f i =
let shouldWork = f (1 :: Int)-- won't actually work
in f i
rankNVersion :: (forall a. a -> a) -> b -> b
rankNVersion f i =
@jroesch
jroesch / TypeFamily.scala
Created April 2, 2014 21:15
TypeFamily example
package typefamily
import scala.language._
/* From the paper:
* http://research.microsoft.com/en-us/um/people/simonpj/papers/assoc-types/fun-with-type-funs/typefun.pdf
*
* class Mutation m where
* type Ref m :: * -> *
* newRef :: a -> m (Ref m a)
@jroesch
jroesch / ghc.rb
Created April 10, 2014 01:45
Hacked up GHC 7.8.1
require 'formula'
class Ghc < Formula
homepage "http://haskell.org/ghc/"
url "https://www.haskell.org/ghc/dist/7.8.1/ghc-7.8.1-src.tar.bz2"
sha1 "7ddfd360be8d25a5d39f3e74573a2ade220511b2"
# bottle do
# revision 2
# sha1 "a6ceeb3f1f9ba2cf0454dc9d45dce69f8a5ae736" => :mavericks
type DDict v = Dict String (Dict String v)
nested : DDict v
nested = ...
-- Let's assume we want to update all inner fields
updateInner :: String -> v -> DDict v -> DDict v
updateInner s v d = Dict.fromList $ (keys d) (map (Dict.insert s v) $ values d)
module HList
data HList : List Type -> Type where
Nil : HList []
(::) : {h: Type} -> {t: (List Type)} -> (head : h) -> (tail : HList t) -> HList (h :: t)
hlist : HList [Int, Int, Int]
hlist = [1, 2, 3]
@jroesch
jroesch / type.hs
Last active August 29, 2015 14:00
data Value = SelfV | Lit Literal
data Literal = IntLit Int | StringLit String | ect
top :: Interpreter (Maybe Value)
top = do
stack <- get
case stack of
[] -> return Nothing
(top:_) -> return $ Just top
@jroesch
jroesch / .emacs.el
Created April 29, 2014 18:35
.emacs.el (for Vineeth)
;; -*- coding: utf-8 -*-
(require 'package)
(setq package-archives '(("gnu" . "http://elpa.gnu.org/packages/")
("marmalade" . "http://marmalade-repo.org/packages/")
("melpa" . "http://melpa.milkbox.net/packages/")))
(package-initialize)
; Remove the pesk + ugly toolbar