Skip to content

Instantly share code, notes, and snippets.

fizbin / regexequiv.hs
Last active Dec 27, 2020
Code to determine whether two regular expressions are equivalent, and if not to find a distinguishing string
View regexequiv.hs
module Main where
-- Takes two arguments in a limited regex-like language, and tells if
-- they are equivalent. This equivalence is shown by either saying
-- "there is no string which matches one regex but not the other" or
-- by giving a string which matches one but not the other.
-- Prints out:
-- First arg. parsed
-- Second arg. parsed
fizbin /
Created Jan 2, 2019
Advent of Code 2018 day 23 solution to handle adversarial input
# AOC 2018 day 23 solution to defeat adversarial input (python3)
# Adversarial input sample can be found
# This will try to open the file given as the first command line argument
# or "" if no argument is given.
# This solution transforms the given coordinates in x-y-z space into 4D
# coordinates in a space I call s-t-u-v space, even though I never actually
# deal with 's', 't', 'u', or 'v' directly.
import itertools
fizbin / RunTM.hs
Last active May 22, 2017
The first Haskell I have evidence of having written
View RunTM.hs
-- This is the first Haskell program of any complexity that I ever wrote, back in October 2005,
-- updated (with newer imports and one changed function name) to run on modern (c. 2017)
-- GHC. It was designed to solve a perl quiz of the week problem to write a Turing
-- Machine emulator. Unfortunately, that mailing list has been defunct for so long that
-- all archives seem to have vanished from the web so I can't point to documentation of
-- the format. I can however point to one program I wrote in the Turing Machine language
-- that solved the prior quiz-of-the-week: given a number N, print out all strings
-- consisting of N '(' characters and N ')' characters such that the parens in the
-- resulting string are balanced.
View Collatz.hs
-- SPOILER for project euler #14
-- Really, you should go do it yourself.
fizbin / util.hs
Last active Aug 29, 2015
Some simple haskell utilities
View util.hs
import qualified Data.Map.Strict as M
-- The code in any functions here should be too small to really be coverable by copyright, but just in case:
Copyright 2014 Daniel Martin
I, Daniel Martin, license this to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
fizbin / LensBuilder.hs
Last active Dec 26, 2015
Experimenting with the Builder pattern in Control.Lens
View LensBuilder.hs
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE Arrows #-}
{- Some ideas on the common Builder pattern from the OO world in the context of lenses -}
module Main where
fizbin / LensHXTPickle.hs
Last active Dec 26, 2015
A little demonstration of HXT and Lenses including a full worked example to show how to pickle an involved data structure to XML.
View LensHXTPickle.hs
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE RankNTypes #-}
{- A little demonstration of HXT and Lenses -}
module Main where
import Control.Arrow