Skip to content

Instantly share code, notes, and snippets.

View timjb's full-sized avatar

Tim Baumann timjb

View GitHub Profile
@timjb
timjb / japanischer-gurkensalat.md
Created July 21, 2012 16:20
Japanischer Gurkensalat

pro Gurke:

  • ca. eine Daumenspitze geriebenen rohen Ingwer
  • 1 gestrichener EL Zucker
  • 1/2 TL Salz
  • Essig
@timjb
timjb / Choice.hs
Created August 1, 2012 11:15
Generalized Either a b
{-# LANGUAGE TemplateHaskell #-}
{-
Inspired by http://www.haskell.org/pipermail/haskell-cafe/2011-June/093358.html
Usage:
{-# LANGUAGE TemplateHaskell #-}
module TestAeson where
import Data.Aeson
import Data.Aeson.Types
import Control.Applicative (Alternative (..))
import Data.Text (unpack)
parserA :: Value -> Parser String
parserA (String s) = return (unpack s)
parserA _ = fail "type mismatch"
@timjb
timjb / test.hs
Created August 18, 2012 00:30
Data.Aeson.Schema.CodeGen
data A
= A_0 {aNumber_1 :: (Data.Maybe.Maybe Data.Attoparsec.Number.Number)}
instance Data.Aeson.Types.Class.FromJSON A_0
where Data.Aeson.Types.Class.parseJSON (Data.Aeson.Types.Internal.Object obj) = Control.Applicative.pure A_0 Control.Applicative.<*> Data.Traversable.traverse (\val -> case val of
Data.Aeson.Types.Internal.Number num -> do Control.Monad.when (num GHC.Classes.>= Data.Attoparsec.Number.I 0) (GHC.Base.fail "number must be greater than or equal 0")
GHC.Base.return num
@timjb
timjb / Test.hs
Created September 10, 2012 15:25
Haskell type system corner cases
{-# LANGUAGE ExistentialQuantification, RankNTypes, ImpredicativeTypes #-}
module Test where
-- doesn't typecheck
test :: IO (forall a. a -> a)
test = return id
test2 :: (forall a. a -> a) -> (forall b. b -> b)
test2 = const id
@timjb
timjb / json-schema-test-suite.json
Created September 15, 2012 14:23
Test suite for JSON schema implementations
{
"description": "Test suite for JSON schema implementations",
"type": "object",
"additionalProperties": {
"type": "object",
"properties": {
"schema": { "$ref": "http://json-schema.org/schema" },
"referencedSchemas": {
"type": "object",
"additionalProperties": { "$ref": "http://json-schema.org/schema" }
{
"recursive schema using $ref": {
"schema": { "$ref": "node" },
"referencedSchemas": {
"node": {
"type": ["object", "string"],
"properties": {
"left": { "$ref": "node" },
"right": { "$ref": "node" }
},
@timjb
timjb / cloud-haskell-operational-transformation.hs
Created October 14, 2012 19:54
Simulation of Operational Transformation with Cloud Haskell
{-
This is a simple simulation of OT with Cloud in which all slaves generate
and apply random operations. It should work in theory. In practice, however
I wasn't apply to test it because my installation of distributed-process is
apparently broken. Specifically, `spawn` doesn't seem to work (I tested it
with some examples from the Well-Typed blog).
This code depends on https://github.com/timjb/haskell-operational-transformation.
-}
@timjb
timjb / AgdaBasics.agda
Created October 15, 2012 21:16
Dependently Typed Programming in Agda
-- I'm following the tutorial at http://www.cse.chalmers.se/~ulfn/papers/afp08/tutorial.pdf
module AgdaBasics where
-- 2.1 Datatypes and pattern matching
data Bool : Set where
true : Bool
false : Bool
@timjb
timjb / johanns-curry.md
Created October 16, 2012 17:53
Johanns vegetarisches Curry

Johanns vegetarisches Curry

Für 6 Personen

Zutaten

Gemüse: