Proposed BFPG lightning talk. 25 slides, 5 minutes, 12 seconds per slide. No problem!
September 2014
Motivation: we want to write something as clear as this, but this is O(n^2).
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.
In a nutshell:
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) |
-- 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) |
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
-- 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 |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
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 |
%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" | |
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 |