Skip to content

Instantly share code, notes, and snippets.

View steshaw's full-sized avatar
👨‍💻
Loves programming languages

Steven Shaw steshaw

👨‍💻
Loves programming languages
View GitHub Profile

Difference Lists

Proposed BFPG lightning talk. 25 slides, 5 minutes, 12 seconds per slide. No problem!

September 2014

1

Motivation: we want to write something as clear as this, but this is O(n^2).

@cmalven
cmalven / craft-fastly.md
Last active August 12, 2020 22:59
Integrating Craft with Fastly

Running a Craft site on Fastly

Fastly is essentially Varnish as a service. Similarly to how Heroku drastically simplifies the running of a web server, Fastly simplifies full-page caching of websites with running with dynamic content.

How Fastly Works

In a nutshell:

  • Every time there is a request for your website, it is routed through Fastly instead of directly to your backend.
  • If Fastly has an existing cache for the requested URL, it serves the cached page and your backend isn't touched at all.
@david-christiansen
david-christiansen / FizzBuzzC.idr
Last active August 29, 2022 20:00
Dependently typed FizzBuzz, now with 30% more constructive thinking
module FizzBuzzC
%default total
-- Dependently typed FizzBuzz, constructively
-- A number is fizzy if it is evenly divisible by 3
data Fizzy : Nat -> Type where
ZeroFizzy : Fizzy 0
Fizz : Fizzy n -> Fizzy (3 + n)
@rwbarton
rwbarton / A.hs
Last active February 2, 2017 09:32 — forked from 23Skidoo/A.hs
-- Code taken from http://stackoverflow.com/questions/12735274/breaking-data-set-integrity-without-generalizednewtypederiving/12744568#12744568
-- Discussion on haskell-cafe: http://thread.gmane.org/gmane.comp.lang.haskell.cafe/100870
-- http://www.haskell.org/pipermail/haskell-cafe/2012-October/103984.html
-- Modified to remove orphan instances by rwbarton
module A where
data U = X | Y deriving (Eq, Ord, Show)
data T u b c = T u b c deriving (Eq, Show)
@conal
conal / backus-denotational-design.md
Last active August 27, 2022 16:54
John Backus on denotation for design

From section 9 of John Backus's 1977 Turing Award lecture Can Programming Be Liberated from the von Neumann Style? A Functional Style and Its Algebra of Programs:

Denotational semantics and its foundations provide an extremely helpful mathematical understanding of the domain and function spaces implicit in programs. When applied to an applicative language (...), its foundations provide powerful tools for describing the language and for proving properties of programs. When applied to a von Neumann language, on the other hand, it provides a precise semantic description and is helpful in identifying trouble spots in the language. But the complexity of the language is mirrored in the complexity of the description, which is a bewildering collection of productions, domains, functions, and equations that is only slightly more helpful in proving facts about programs than the reference manual of the language, since it is less ambiguous.

...

Thus

@pchiusano
pchiusano / tagging.haskell
Last active August 29, 2015 14:03
Using tagged dictionaries to ensure coherency in Haskell
-- Demonstrates how to ensure coherence when representing typeclasses with first-class dictionaries
newtype Tag t a = Tag { untag :: a } -- constructor kept private
use :: a -> (forall t . Tag t a -> b) -> b -- tagged values introduced in a stack discipline
-- Example, a 'first-class' Ord
newtype Ord a = Ord { ordering :: a -> a -> Ordering }
-- Ensure coherence when using this with Set
@staltz
staltz / introrx.md
Last active April 19, 2025 05:15
The introduction to Reactive Programming you've been missing
object ScalaJSExample extends js.JSApp{
def main() = {
val xs = Seq(1, 2, 3)
println(xs.toString)
val ys = Seq(4, 5, 6)
println(ys.toString)
val zs = for{
x <- xs
y <- ys
} yield x * y
@LeifW
LeifW / postulate.hs
Last active August 29, 2015 14:02
Use of postulate in Idris typeclass law
%default total
class Semigroupy a where
op: a -> a -> a
semigroupOpIsAssociative : (x, y, z : a) -> op x (op y z) = op (op x y) z
instance Semigroupy Int where
op = (+)
semigroupOpIsAssociative x y z = believe_me "sure, yeah, whatever"
@tonymorris
tonymorris / bikes-for-rob.md
Last active August 29, 2015 14:01
Bikes for Rob

DR650 DR-Z400 XR650 KTM690 WR450 TE510
Highway handling 9 5 7 9 3 1
Highway engine 9 6 6 7 4 2
Carrying 9 5 5 6 3 2
Off-road handling 2 6 4 7 8 9
Off-road engine 5 7 6 7 8 9
Up-front cost 9 9 8 2 5 2
Ongoing cost 9 8 8 2 4 2