Skip to content

Instantly share code, notes, and snippets.

View acowley's full-sized avatar

Anthony Cowley acowley

  • Philadelphia, PA, USA
View GitHub Profile
@acowley
acowley / flake.nix
Created December 11, 2021 18:05
Nix flake for building Frames-streamly
{
description = "Frames-streamly";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils";
hls.url = "github:haskell/haskell-language-server";
};
outputs = { self, nixpkgs, flake-utils, hls }:
flake-utils.lib.eachDefaultSystem (system:
{-# LANGUAGE MagicHash, UnboxedTuples #-}
import GHC.Prim
import GHC.Types
main :: IO ()
main = do
xb@(I# x) <- fmap read getLine
case addWordC# 5## (int2Word# x) of
(# res, carryFlag #) ->
putStrLn ("5 + " ++ show xb ++ " = " ++ show (W# res))
@acowley
acowley / CMakeLists.txt
Created October 13, 2017 14:44
Nix packaging of the PCL visualizer demo
cmake_minimum_required(VERSION 2.6 FATAL_ERROR)
project(pcl_visualizer_viewports)
find_package(PCL 1.2 REQUIRED)
include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})
@acowley
acowley / gd.nix
Created July 15, 2016 03:36
A bump of libgd to 2.2.2 and a cherry-picked patch to fix on Darwin
{ stdenv, fetchurl, fetchpatch, autoreconfHook, perl
, pkgconfig
, zlib
, libpng
, libjpeg ? null
, libwebp ? null
, libtiff ? null
, libXpm ? null
, fontconfig
, freetype
@acowley
acowley / Compiler.hs
Created December 22, 2015 18:17
Use the GHC API to time the type checker
import Control.Arrow ((***))
import Control.Monad (replicateM_)
import Control.Monad.IO.Class
import Data.List (isPrefixOf)
import Data.Time.Clock
import DynFlags (defaultFatalMessager, defaultFlushOut, PkgConfRef(PkgConfFile))
import GHC
import GHC.Paths (libdir)
import System.FilePath (takeBaseName, splitExtension, addExtension)
import Text.Printf
{-# LANGUAGE DataKinds, TypeFamilies, UndecidableInstances #-}
import Control.Monad (join)
import Criterion.Main
import Data.Functor.Identity
import Data.Vinyl
import Data.Vinyl.TypeLevel
class Eq2 a where
eq2 :: a -> a -> Bool
@acowley
acowley / Cocreature.hs
Created May 22, 2015 02:33
Declaring columns in Frames
{-# LANGUAGE OverloadedStrings, QuasiQuotes, RankNTypes #-}
{-# LANGUAGE DataKinds, FlexibleContexts, TemplateHaskell, TypeOperators #-}
import Frames
import Frames.ColumnUniverse
import Frames.CSV
import Lens.Family
import Pipes
-- Manually declared columns using a TH helper
declareColumn "x2" ''Double
@acowley
acowley / Main.hs
Created May 22, 2015 00:37
Basic array processing
import Criterion.Main
import qualified Data.Vector.Unboxed as V
go :: V.Vector Int -> Int
go = V.sum . V.filter (< 10) . V.map (+ 5)
main :: IO ()
main = do defaultMain [ bench "mapFilterSum" $ whnf go v ]
putStrLn $ "The answer was " ++ show (go v) ++ ", btw"
where v = V.generate n id
@acowley
acowley / StateDemo.hs
Created February 17, 2015 01:21
No Transformer Stack
{-# LANGUAGE DataKinds, FlexibleContexts, TypeOperators #-}
import Control.Monad.State
import Data.Vinyl
type OuterData = '("Outer", String)
type InnerData = '("Inner", String)
outerData :: SField OuterData
outerData = SField
@acowley
acowley / EmacsHaskellDemo.md
Last active May 18, 2023 17:31
Emacs Haskell Demo Show Notes

Org Editing in haskell-mode

The video opens with a regular Haskell source file in haskell-mode. We start off by adding headings that break the file into meaningful chunks. A section heading is indicated by an asterisk following Haskell single-line comment characters, i.e. -- *. These are top-level headings, sub-headings are indicated by adding more asterisks.

These section markers are given meaning by