This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Playground - noun: a place where people can play | |
protocol ℕ { | |
static func construct() -> Self | |
static var value : UInt { get } | |
} | |
struct Zero : ℕ { | |
static func construct() -> Zero { | |
return Zero() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class F<A> { | |
} | |
protocol Functor { | |
typealias A | |
typealias B | |
typealias FA = F<A> | |
typealias FB = F<B> | |
func fmap(a: FA, fn: (A -> B)) -> FB | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protocol Monad { | |
typealias F | |
typealias U | |
class func bind<M : Monad where M.U == U>(Self, F -> M) -> M | |
class func `return`(F) -> Self | |
} | |
extension Array : Monad { | |
typealias F = T |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define self \ | |
( \ | |
_Pragma("clang diagnostic push") _Pragma("clang diagnostic ignored \"-Wunused-value\"") self, \ | |
/* Depends on _cmd being a const copy, like other captured variables. */ \ | |
_Pragma("clang diagnostic pop") (*(_cmd = _cmd, &self)) \ | |
) | |
// Replace libextobjc's @weakify with one that's aware of the "self" macro. | |
#undef ext_weakify_ | |
#define ext_weakify_(INDEX, CONTEXT, VAR) \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE OverloadedStrings, DeriveDataTypeable, NoMonomorphismRestriction #-} | |
module AesonTest where | |
import qualified Data.Aeson.Generic as A | |
import qualified Data.ByteString.Lazy as L8 | |
import Data.Data | |
import Data.Typeable | |
import Codec.Binary.UTF8.String as U8 | |
import Data.Maybe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# unregister broken GHC packages. Run this a few times to resolve dependency rot in installed packages. | |
# ghc-pkg-clean -f cabal/dev/packages*.conf also works. | |
function ghc-pkg-clean() { | |
for p in `ghc-pkg check $* 2>&1 | grep problems | awk '{print $6}' | sed -e 's/:$//'` | |
do | |
echo unregistering $p; ghc-pkg $* unregister $p | |
done | |
} | |
# remove all installed GHC/cabal packages, leaving ~/.cabal binaries and docs in place. |