This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Example code for a CSV file parser using Parsec. Some parts are | |
-- repeated, with differing functionality. To avoid name conflicts, | |
-- comment out the versions you don't want to play with. | |
module CSVParser (parseCSV, parseCSV') where | |
import Control.Applicative ((<$), (<*), (*>), liftA) | |
import Data.Char (chr) | |
import Data.Either (either) | |
import Text.Parsec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
worker_processes 1; | |
error_log logs/error.log; | |
events { | |
worker_connections 1024; | |
} | |
http { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
id :: TVar 1 :-> TVar 1 | |
\a -> a | |
const :: TVar 1 :-> (TVar 2 :-> TVar 1) | |
\a -> \b -> a | |
fst :: TVar 1 :.: TVar 2 :-> TVar 1 | |
\a@(b,c) -> b | |
snd :: TVar 1 :.: TVar 2 :-> TVar 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Markov Chain. | |
Pass input to stdin. | |
Usage: | |
markov <len> [-n <n>] [-p <p>] [-c] [-s <s>] | |
markov -h | --help | |
Options: | |
<len> The length (in tokens) of the output to generate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; The stack pointer is going to be an index into the stack, and the | |
; stack is an array of words. The alternative would be to have the | |
; stack pointer me a pointer to memory, but this is perhaps a bit | |
; nicer, as where the stack actually lives is totally irrelevant. | |
@stack = global [1000 x i64] undef | |
@sp = global i64 undef; | |
; Now we have the basic stack operations: push, pop, and peek. As can | |
; be seen from the definitions, LLVM is typed, which is really nice as |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Initial 179e.cabal generated by cabal init. For further documentation, | |
-- see http://haskell.org/cabal/users-guide/ | |
name: 179e | |
version: 0.1.0.0 | |
-- synopsis: | |
-- description: | |
homepage: http://www.reddit.com/r/dailyprogrammer/comments/2ftcb8/9082014_challenge_179_easy_you_make_me_happy_when/ | |
-- license: | |
license-file: LICENSE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/zsh | |
export PATH="/home/barrucadu/.cabal/bin:$PATH" | |
export LANG=en_GB.UTF-8 | |
export LC_ALL=en_GB.UTF-8 | |
export LC_CTYPE=en_GB.UTF-8 | |
WEBDIR=/srv/http/barrucadu.co.uk/.build | |
export GIT_WORK_TREE=$WEBDIR |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
---------------------------------------------------- | |
-- The 'Find' monad | |
-- | A 'Find' computation of type represents a search problem which may result in an 'a' (or nothing at all) operating in a monad 'm'. The contract is that if there are any 'a's which could be returned, then one must be. | |
newtype Find m a = Find { unFind :: m (Maybe a) } | |
instance MonadConc m => Functor (Find m) where | |
fmap f (Find ma) = Find $ fmap (fmap f) ma | |
instance MonadConc m => Applicative (Find m) where |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Acyclicity test | |
& 2x2 grid & 6 & 1 & 0 & 4 & $<0.01$ & & | |
& 3x3 grid & 19770 & 1 & 0 & 12 & 7.58 & & | |
& 4x4 grid & - & - & - & - & $>5m$ & & - & - \\ | |
& cyclic 1000 & 0 & 0 & 1000 & 0 & 1.38 & & | |
& cyclic 100 & 0 & 0 & 100 & 0 & 0.03 & & | |
& cyclic 500 & 0 & 0 & 500 & 0 & 0.36 & & | |
\hline | |
Rooted 2 colouring | |
& 2x2 grid & 0 & 0 & 0 & 0 & $<0.01$ & & |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Main where | |
import Control.Applicative | |
import Control.Concurrent.Find | |
import Control.DeepSeq | |
import Data.List | |
import Debug.Trace | |
data BinTree = Leaf | Branch Int BinTree BinTree deriving Eq |