Skip to content

Instantly share code, notes, and snippets.

View cartazio's full-sized avatar

Carter Tazio Schonwald cartazio

View GitHub Profile
%====Set up Listings===============================================================
\definecolor{darkgreen}{rgb}{0,0.5,0}
\definecolor{darkred}{rgb}{0.5,0,0}
\lstloadlanguages{Haskell}
\lstnewenvironment{code}
{ % \centering
\lstset{}%
\csname lst@SetFirstLabel\endcsname}
{ %\centering
@copumpkin
copumpkin / Format.hs
Last active August 29, 2015 13:57
A simple translation of the format combinators used in The Power of Pi (http://www.staff.science.uu.nl/~swier004/Publications/ThePowerOfPi.pdf)
{-# LANGUAGE EmptyDataDecls, ExistentialQuantification, RankNTypes, GADTs, ImplicitParams, TypeFamilies, DataKinds, TypeOperators, DeriveGeneric, PolyKinds #-}
module Format where
import Prelude hiding (read)
import Data.Either
import Data.Binary.Get
import Data.Binary.Builder
import Data.Monoid
import Data.Foldable
import Control.Applicative
@copumpkin
copumpkin / Resource.hs
Last active August 29, 2015 13:58
Can you break my shitty linear resource monad transformer? Looking for people to find ways that it's unsafe.
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE LiberalTypeSynonyms #-}
{-# LANGUAGE ImplicitParams #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE RebindableSyntax #-}
module Resource where
@ekmett
ekmett / Tarjan.hs
Last active August 29, 2015 14:03
{-# LANGUAGE RankNTypes, GADTs, PolyKinds #-}
module Tarjan where
import Control.Applicative
import Control.Category
import Data.Monoid
import Prelude hiding ((.),id)
-- Radu Mihaesau and Robert Tarjan's Catenable Deque
class (Ord (Key table)) => OrderedKV table where
type Key table :: *
type Value table ::*
type Address table :: *
keyRange :: table -> (Key table, Key table)
key2Address :: table -> (Key table) -> Maybe (Address table)
address2Key :: table -> (Address table) -> Key Table
nextAddress :: table -> Address table -> Maybe (Address table)
nextKey :: table -> Key table -> Maybe (Address table) ->Maybe (Key table, Address table )
{-# LANGUAGE ScopedTypeVariables #-}
module Rendering.CLGLBuffer where
import Control.Parallel.CLUtil
import Foreign.Ptr (nullPtr)
import Foreign.Storable (Storable(sizeOf))
import Graphics.GLUtil.BufferObjects
import Graphics.Rendering.OpenGL (deleteObjectName, BufferObject, BufferTarget(..))
import Rendering.CLGLInterop
data CLGLBuffer a = CLGLBuffer { asVBO :: BufferObject
anonymous
anonymous / gist:1194308
Created September 5, 2011 07:27
Smarter do notation desugaring
module Main where
import qualified Data.Set as S
type Var = String
-- For the purposes of the desugaring the only important thing
-- about the nested terms are the free variables
data HsTerm = HsTerm { dsHsTerm' :: String, hsTermFVs' :: [Var] }
@deepakjois
deepakjois / README.md
Created January 26, 2012 17:30 — forked from cartazio/gist:1655271
Installing GHC 7.2.2 and diagrams on OS X Lion

Installing GHC 7.2.2 and diagrams on OS X Lion

Install prerequisites

GHC 7.2.2 64-bit

Make sure you have the 64-bit version of GHC. If you installed GHC using brew install haskell-platform, you are using the 32-bit version which wont work with the instructions below. To install the 64-bit version

  • Follow instructions in this [gist][ghcinstallgist]. However, note that the patch for cabal-install that they point to is not available anymore. There is a similar patch in [this gist][cabalinstallgist], which worked for me. Read [this comment][cabalinstallcomment] for more info on how to apply the patch.
anonymous
anonymous / Hdfs.hs
Created March 19, 2012 17:19
A Haskell API wrapping libhdfs
module System.Hdfs where
import Data.ByteString (ByteString)
import qualified Data.ByteString as B
import Data.Int
import Data.Vector (Vector)
import Data.Word
import Foreign.Ptr
type Size = Int32
@ekmett
ekmett / Remote.hs
Created August 4, 2012 16:46
remote dsl
{-# LANGUAGE GADTs, Rank2Types, KindSignatures, ScopedTypeVariables, TypeOperators, DataKinds, PolyKinds, MultiParamTypeClasses, FlexibleInstances, TypeFamilies, DoRec, ExtendedDefaultRules #-}
import Control.Applicative
import Control.Category
import Control.Comonad
import Control.Monad.Fix
import Control.Monad (ap)
import Data.Functor.Identity
import Data.Typeable
import Data.Monoid
import Data.Unique