Skip to content

Instantly share code, notes, and snippets.

View jtdaugherty's full-sized avatar

Jonathan Daugherty jtdaugherty

  • Galois, Inc.
  • Portland, OR
View GitHub Profile
cygnus=# create table parent (a text not null primary key);
CREATE TABLE
cygnus=# create table child (a text not null primary key references parent(a) on delete cascade on update cascade);
CREATE TABLE
cygnus=# insert into parent (a) values ('foobar');
INSERT 0 1
cygnus=# insert into parent (a) values ('foo__bar');
INSERT 0 1
cygnus=# insert into child (a) values ('foo');
ERROR: insert or update on table "child" violates foreign key constraint "child_a_fkey"
@jtdaugherty
jtdaugherty / ListDemo.hs
Created December 25, 2017 17:56
Multi-selection list demo
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE OverloadedStrings #-}
module Main where
import Lens.Micro.Platform ((^.), _1, (%~), (&), ix)
import Control.Monad (void)
import Data.Monoid
import Data.Maybe (fromMaybe)
import qualified Graphics.Vty as V
@jtdaugherty
jtdaugherty / RLE.hs
Created October 5, 2012 16:28
Text editor zipper
module RLE where
import Control.Applicative
import Data.Monoid
newtype RLE a = RLE [(Int, a)]
instance Monoid (RLE a) where
mempty = RLE []
mappend (RLE as) (RLE bs) = RLE (as `mappend` bs)
@jtdaugherty
jtdaugherty / test.hs
Created March 27, 2012 18:25
Parsec + Haskell stuff
module Main where
import Text.ParserCombinators.Parsec
( Parser
, parse
, string
@jtdaugherty
jtdaugherty / Rules.hs
Created January 8, 2012 07:47
Experimenting with structured data validation with validated "residues"
{-# OPTIONS_GHC -Wall #-}
{-# LANGUAGE GADTs #-}
module Rules
( Rule(Rule)
, foreach
, failRule
, apply
, ruleDoc
)
where