Skip to content

Instantly share code, notes, and snippets.

View wenkokke's full-sized avatar

Wen Kokke wenkokke

View GitHub Profile
@wenkokke
wenkokke / anbn.input
Last active March 14, 2016 14:36
Grammars for aⁿbⁿ and aⁿbⁿcⁿ using constraint grammar (using only REMOVE).
"<w>"
"a"
"b"
"opt_a"
"opt_b"
"odd"
"even"
"^"
"$"
"<w>"
@wenkokke
wenkokke / Makefile
Last active June 24, 2016 13:19
A simple makefile which delegates every task to a Shake build file.
BUILDFILE := ./buildfile.hs
BUILD := ./_build/build
BUILDDIR := $(dir $(BUILD))
SOURCES := $(shell find .)
SOURCES := $(filter-out ./Makefile,$(SOURCES))
SOURCES := $(filter-out $(BUILD),$(SOURCES))
SOURCES := $(filter-out $(BUILDFILE),$(SOURCES))
# Delegate the default task.
default:
@wenkokke
wenkokke / AB_grammar.hs
Last active January 24, 2024 14:51
AB grammars and extensible effects can do some fun things—depends on Eff1.hs found on <http://okmij.org/ftp/Haskell/extensible/>
{-# LANGUAGE TemplateHaskell, QuasiQuotes, FlexibleInstances, FlexibleContexts,
TypeFamilies, GADTs, TypeOperators, DataKinds, PolyKinds, RankNTypes,
KindSignatures, UndecidableInstances, StandaloneDeriving,
RecordWildCards, DeriveFunctor, DeriveFoldable, DeriveTraversable #-}
module AB where
import Prelude hiding (lookup, lex)
import Control.Applicative ((<|>),empty)
import Data.Maybe (maybeToList)
@wenkokke
wenkokke / agda2_compute_toplevel.hs
Last active September 3, 2015 10:50
Script which loads a given file into Agda and prints the normalised form of a given expression.
module agda2_compute_toplevel where
import Control.Concurrent (forkIO)
import Data.List (isPrefixOf)
import System.Environment (getEnv)
import System.FilePath (splitSearchPath)
import System.IO
import System.Process
import Text.Printf (printf)
@wenkokke
wenkokke / main.agda
Last active October 31, 2023 20:37
Code extracted from "Formalising type-logical grammars in Agda".
-- This file contains the code from the paper "Formalising
-- type-logical grammars in Agda", and was directly extracted from the
-- paper's source.
--
-- Note: because the symbol customarily used for the "left difference"
-- is unavailable in the Unicode character set, and the backslash used
-- for implication is often a reserved symbol, the source file uses a
-- different notation for the connectives: the left and right
-- implications are represented by the double arrows "⇐" and "⇒", and
@wenkokke
wenkokke / Unlit.lhs
Last active August 29, 2015 14:21
A simple script for converting literate code to code.
> {-# LANGUAGE OverloadedStrings, RecordWildCards, TupleSections, DeriveFunctor #-}
> module Unlit where
> import Control.Arrow (first,second)
> import Data.List (foldl')
> import Data.Text (Text)
> import qualified Data.Text as T
> import qualified Data.Text.IO as T
@wenkokke
wenkokke / dropbox.sh
Last active August 29, 2015 14:16
Bash command for Dropbox Share...
DROPBOX_SIZE_LIMIT=3000
DROPBOX_FOLDER="$HOME/Dropbox"
DROPBOX_SHARED_INDEX="$DROPBOX_FOLDER/Shared/.index"
function share {
current=`du -s $DROPBOX_FOLDER | cut -f1`
# with no arguments, echo current usage
if [ "$#" -eq 0 ]; then
@wenkokke
wenkokke / lastmd.hs
Last active August 29, 2015 14:07
A (probably very unidiomatic) Shake script which renders the last modified Markdown to a PDF using Pandoc/LaTeX.
{-# LANGUAGE DeriveDataTypeable #-}
import Control.Applicative ((<$>))
import Control.Monad (filterM)
import Data.Foldable (or)
import Data.List (isSuffixOf,maximumBy)
import Data.Ord (comparing)
import Data.Traversable (traverse)
import Development.Shake
import Development.Shake.FilePath
@wenkokke
wenkokke / rendertree.hs
Last active April 1, 2017 18:15
Pandoc filter which renders simple brace-delimited trees in codeblocks to LaTeX's Tikz-QTree...
#!/usr/bin/env runhaskell
-- cabal depedencies:
--
-- * containers
-- * pandoc-types
-- * uu-parsinglib
--
{-# LANGUAGE RankNTypes #-}
@wenkokke
wenkokke / Apply.hs
Last active August 29, 2015 14:05
An implementation of an "apply" type-class which allows for overloading "function application".
{-# LANGUAGE GADTs #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE UndecidableInstances #-}