Skip to content

Instantly share code, notes, and snippets.

View CRogers's full-sized avatar

Callum Rogers CRogers

View GitHub Profile
@CRogers
CRogers / 0_FParsecTrace.fs
Last active February 8, 2020 21:41
A pretty printed debug tracer for FParsec - like [the example from the docs](http://www.quanttec.com/fparsec/users-guide/debugging-a-parser.html#tracing-a-parser) but with nicer syntax and saves the output in `UserData.Debug`. Use the same ways as in the docs - `parser <!> "label"` will trace the entrance, exit, result and data produced by `pars…
module FParsecTrace
open FParsec
open FParsec.Primitives
open FParsec.CharParsers
open System.Text
type DebugInfo = { Message: string; Indent: int }
type UserState = { mutable Debug: DebugInfo }
@CRogers
CRogers / default.nix
Last active August 29, 2015 14:04
libsndlib minimal nix
{ pkgs ? (import <nixpkgs> {}) }:
pkgs.stdenv.mkDerivation rec {
name = "test";
version = "1";
buildInputs = with pkgs; [ libsndfile ];
}
@CRogers
CRogers / Cats.hs
Last active August 29, 2015 14:10
Ambiguity error with higher order lists and type families
{-# LANGUAGE KindSignatures, DataKinds, TypeFamilies, TypeOperators, GADTs, FlexibleInstances, FlexibleContexts #-}
module Foo where
data HList as where
HNil :: HList '[]
HCons :: a -> HList as -> HList (a ': as)
instance Show (HList '[]) where
show _ = "[]"
@CRogers
CRogers / Testing.hs
Created November 30, 2014 23:57
Reactive Banana Test
{-# LANGUAGE Rank2Types #-}
module Testing where
import Data.IORef
import Control.Monad (forever, forM)
import System.IO (BufferMode(..), hSetEcho, hSetBuffering, stdin)
import Reactive.Banana
import Reactive.Banana.Frameworks
@CRogers
CRogers / virtual-dom.js
Created February 19, 2015 14:53
virtual-dom dist @ 3ea4f0e
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.virtualDom=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
var createElement = require("./vdom/create-element.js")
module.exports = createElement
},{"./vdom/create-element.js":15}],2:[function(require,module,exports){
var diff = require("./vtree/diff.js")
module.exports
@CRogers
CRogers / virtual-dom-e34dd82.js
Created February 19, 2015 23:13
virtual-dom @ e34dd82
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.virtualDom=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
var createElement = require("./vdom/create-element.js")
module.exports = createElement
},{"./vdom/create-element.js":15}],2:[function(require,module,exports){
var diff = require("./vtree/diff.js")
module.exports
@CRogers
CRogers / virtual-dom-d9bd81d.js
Created February 20, 2015 11:04
virtual-dom @ d9bd81d
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.virtualDom=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
var createElement = require("./vdom/create-element.js")
module.exports = createElement
},{"./vdom/create-element.js":15}],2:[function(require,module,exports){
var diff = require("./vtree/diff.js")
module.exports
@CRogers
CRogers / gist:ff13285fe67acec9ad6a
Last active August 29, 2015 14:23
Roman Numerals in Haskell
module Main where
import Data.List
data Numeral = Numeral Int String
numerals :: [Numeral]
numerals = reverse [
Numeral 1 "I",
Numeral 4 "IV",
@CRogers
CRogers / Setup.hs
Created August 16, 2015 12:06
Stack ide errors with ghc 7.8
import Distribution.Simple
main = defaultMain
module OneSourceError where
expr :: String
expr = 1 ++ "str"