Skip to content

Instantly share code, notes, and snippets.

@msakai
msakai / TuplingExample.hs
Created March 25, 2011 14:36
タプル化の簡単な例
module TuplingExample where
import Prelude hiding (even, odd)
even :: Int -> Bool
even n = if n==0 then True else odd (n-1)
odd :: Int -> Bool
odd n = if n==0 then False else even (n-1)
@NicolasT
NicolasT / functors.v
Created May 2, 2011 21:50
Coq definitions and proofs of several functors
Require Import Coq.Program.Basics.
Open Local Scope program_scope.
Definition id (A: Type) (e: A): A := e.
Module Type FUNCTOR.
Set Implicit Arguments.
Parameter F: forall (A: Type), Type.
Parameter fmap: forall (A B: Type), (A -> B) -> F A -> F B.
@sebfisch
sebfisch / GenericFoldableTraversable.hs
Created July 30, 2011 01:15
Generic implementation of Foldable and Traversable instances
{-# LANGUAGE TypeFamilies, TypeOperators, FlexibleContexts #-}
module GenericFoldableTraversable where
import Data.Monoid ( Monoid, mappend, mempty )
import Data.Foldable ( Foldable, foldMap )
import Control.Applicative ( Applicative, pure, (<*>) )
import Data.Traversable ( Traversable, traverse )
@konn
konn / possibleworld.als
Created August 30, 2011 12:34
クリプキ可能世界意味論を、Alloy で。
module possibleworld
sig World {}
sig Atom {}
enum TruthValue { True, False }
sig KripkeFrame {
worlds : some World,
accessible: World -> World
}
@hellerbarde
hellerbarde / latency.markdown
Created May 31, 2012 13:16 — forked from jboner/latency.txt
Latency numbers every programmer should know

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs

@machty
machty / router-facelift-guide.md
Last active July 10, 2024 15:14
Guide to the Router Facelift

Ember Router Async Facelift

The Ember router is getting number of enhancements that will greatly enhance its power, reliability, predictability, and ability to handle asynchronous loading logic (so many abilities), particularly when used in conjunction with promises, though the API is friendly enough that a deep understanding of promises is not required for the simpler use cases.

@cartazio
cartazio / xcode5-haskell-directions.md
Last active May 28, 2019 00:35
xcode 5 + OS X 10.9 mavericks GHC work around nuttiness

PSA :

just use GHC for OSX https://ghcformacosx.github.io

the rest of these directions are preserved for historical purposes

TLDR version, if you have homebrew

xcode-select --install ; brew tap homebrew/versions ;   brew tap homebrew/dupes \
module FoldZipFusion {a b c d} {A : Set a} {B : Set b} {C : Set c} {D : Set d} (_⊕_ : A → B → B) (_⊗_ : C → D → A)where
open import Function
open import Data.List
open import Relation.Binary.PropositionalEquality
_⊛_ : {z : B} → C → (List D → B) → List D → B
_⊛_ {z} x k [] = z
_⊛_ {z} x k (y ∷ ys) = (x ⊗ y) ⊕ k ys
{-# LANGUAGE
FlexibleInstances,
FlexibleContexts,
UndecidableInstances,
MultiParamTypeClasses,
GADTs,
ConstraintKinds,
ScopedTypeVariables,
TypeOperators
#-}
@edsko
edsko / CheckedRevisited.hs
Last active November 3, 2021 08:35
Lightweight checked exceptions in Haskell without `unsafeCoerce`
{-# OPTIONS_GHC -Wall -fno-warn-unused-binds #-}
{-# LANGUAGE CPP #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE IncoherentInstances #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
#if __GLASGOW_HASKELL__ >= 708
{-# LANGUAGE RoleAnnotations #-}
#endif