Skip to content

Instantly share code, notes, and snippets.

View rrnewton's full-sized avatar

Ryan Newton rrnewton

View GitHub Profile
@rrnewton
rrnewton / Output.hs
Created June 29, 2015 13:34
Output of lowerDict on "p4"
Prog [DDef {tyName = TypeDict,
kVars = [(a, Star)],
cVars = [],
sVars = [],
cases = [KCons {conName = ArrowTyDict,
fields = [ConTy TypeDict [VarTy a],ConTy TypeDict [VarTy b]],
outputs = [ConTy ArrowTyDict [VarTy a,VarTy b]]},
KCons {conName = IntDict,
fields = [],
@rrnewton
rrnewton / bad_output.hs
Last active August 29, 2015 14:24
Bad output with unfinished bits
{-# LANGUAGE GADTs #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# OPTIONS_GHC -fdefer-type-errors #-}
module Ghostbuster where
import Prelude hiding (Int, Maybe(..), Bool(..))
data TypeDict a where
data TyEquality a b where
Refl :: TyEquality a a
@rrnewton
rrnewton / SpecList.hs
Created August 5, 2015 01:11
SpecList
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE ScopedTypeVariables #-}
module Main where
import Data.Proxy
class SpecList a where
type List a :: *
@rrnewton
rrnewton / Future.hs
Created August 24, 2015 22:55
For Omer
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE MagicHash #-}
-- |
module Data.LVar.Future where
import Control.DeepSeq
import Control.Exception (throw)
@rrnewton
rrnewton / Main.hs
Created September 3, 2015 14:44
Stack docker hello world (getting errors)
main = print "hello world"
@rrnewton
rrnewton / random cabal attempt.txt
Last active September 5, 2015 02:05
Random attempt on a random laptop to install the same package in stack and cabal
$ cabal --version
cabal-install version 1.20.1.0
$ cabal install turtle
Resolving dependencies...
Configuring ansi-wl-pprint-0.6.7.3...
Downloading clock-0.5.1...
Configuring hostname-1.0...
Configuring managed-1.0.0...
Configuring optional-args-1.0.0...
Building ansi-wl-pprint-0.6.7.3...
@rrnewton
rrnewton / results0.1
Created February 24, 2012 15:51
Current performance (latency) of different network-transport backends
This is the average latency as measured by a single trial run of 100K ping/pongs with several different transports.
PingTCP: 7.34s >80%CPU
PingTCPTransport: 19s ~60%CPU
PingPipes: 6.36s >=100%CPU
The machine is a 3.1 ghz Intel Westmere (Dell workstation) running RHEL 6.2.
The PingTCP is a baseline that uses the raw Network.Socket interface rather than the Network.Transport abstraction.
@rrnewton
rrnewton / forksplit_sketch.hs
Created April 2, 2012 18:36
A sketch of what types for an ST + Par + MVector combination
{-# LANGUAGE RankNTypes, GeneralizedNewtypeDeriving, CPP #-}
import Data.Vector.Mutable as MV
import qualified Data.Vector as V -- ((!), freeze)
import Control.Monad.ST
import Control.Monad.Primitive
import Prelude hiding (read)
type Splitter a = a -> (a,a)
@rrnewton
rrnewton / meta-par-accelerate_blog_post.lhs
Created May 4, 2012 19:19
meta-par-accelerate blog post
> module Main where
How to write hybrid CPU/GPU programs with Haskell
-------------------------------------------------
What's better than programming a GPU with a high-level,
Haskell-embedded DSL (domain-specific-language)? Well, perhaps
writing portable CPU/GPU programs that utilize both pieces of
@rrnewton
rrnewton / magnitude.hs
Created May 14, 2012 05:09
Better Haskell magnitude
import Data.Complex
-- This should be the biggest representable double:
big :: Double
big = 1.7976931348623157e308
-- This uses OCaml's approach at overflow-avoidance:
mag :: Complex Double -> Double
mag (x:+y) =