Skip to content

Instantly share code, notes, and snippets.

View timjb's full-sized avatar

Tim Baumann timjb

View GitHub Profile
import Test.QuickCheck
import Control.Applicative ((<$>))
import Data.List (scanl)
-- To test whether my timsort implementation has the bug described in
-- http://envisage-project.eu/proving-android-java-and-python-sorting-algorithm-is-broken-and-how-to-fix-it/
-- Answer: yes :-(
runLengthInvariantBroken :: (Num i, Ord i) => i -> i -> i -> i -> Bool
runLengthInvariantBroken a b c i = (b - a <= i - b) || (c - b <= i - c)
@timjb
timjb / veganes-mousakas.md
Last active August 29, 2015 14:15
Veganes Mousakás

Veganes Mousakás

(Rezept von Nina Baumann)

Zutaten

(für eine kleine Auflaufform, 3-4 Personen)

  • 200g Sojagranulat
  • 1l Gemüsebrühe
{-# LANGUAGE BangPatterns #-}
module Main (main) where
import Criterion.Main
import Data.Bits
main :: IO ()
main = defaultMain benchmarks
where
@timjb
timjb / SubstIrrelevant.agda
Created January 27, 2015 17:24
Substitution in Agda with irrelevant propositional equality for data types with decidable equality
module SubstIrrelevant where
open import Data.Empty
open import Relation.Binary.PropositionalEquality
open import Relation.Binary
open import Relation.Nullary
-- Irrelevant in ⊥
⊥-elim′ : ∀ {w} {Whatever : Set w} → .⊥ → Whatever
⊥-elim′ ()
module IrrelevantTest where
open import Relation.Nullary.Core
open import Data.Empty
⊥-elim′ : ∀ {w} {Whatever : Set w} → .⊥ → Whatever
⊥-elim′ ()
test : {A : Set} → .A → Dec A → A
test a (yes p) = p
-- developed for https://gist.github.com/timjb/e3e85f961781b088e88b
module Main where
import Control.Monad (forM_)
import Data.Monoid ((<>))
data Action = Noop | InsertChar | RetainChar | DeleteChar | InsertTombstone | RetainTombstone
deriving (Show, Eq, Ord)
-- this agda module depends on https://github.com/copumpkin/categories
-- inspired by https://gist.github.com/aristidb/1746133
open import Level
open import Categories.Category
open import Categories.Functor.Core
open import Categories.Agda
open import Categories.Product
--open import Categories.Bifunctor
@timjb
timjb / OTCategory.agda
Last active August 29, 2015 14:13
Formalization of OT with tombstones
-- this agda module depends on https://github.com/copumpkin/categories
module Categories.OTCategory (C : Set) where
-- inspired by https://gist.github.com/aristidb/1746133
open import Level
open import Categories.Category
open import Categories.Functor.Core
open import Categories.Agda
@timjb
timjb / .gitignore
Last active November 12, 2017 13:42
*.agdai
{-# OPTIONS --universe-polymorphism #-}
-- this agda module depends on https://github.com/copumpkin/categories
open import Categories.Category
module Categories.InternalLanguage {o ℓ e} (C : Category o ℓ e) where
open Category C
open Equiv