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
This is a literate Haskell file that describes the sketch of a type-safe URL | |
handling system. It is not done (or anything near it), but is intended as | |
inspiration for a complete system. | |
First we will show some examples, and later we will implement the library. The | |
library uses the |regular| package for generic programming (cabal install regular). | |
> {-# LANGUAGE TemplateHaskell, TypeFamilies, EmptyDataDecls, | |
> TypeSynonymInstances, TypeOperators, ScopedTypeVariables #-} | |
> |
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 GADTs, TypeOperators, TupleSections #-} | |
> module Routing2 where | |
> import Control.Applicative hiding (many, (<|>)) | |
> import Text.ParserCombinators.Parsec.Prim | |
> import Text.ParserCombinators.Parsec.Error | |
> import Text.ParserCombinators.Parsec.Char | |
> import Text.ParserCombinators.Parsec.Combinator | |
> import Data.List (intercalate) |
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
import Cocoa | |
enum CoroutineState { | |
case Fresh, Running, Blocked, Canceled, Done | |
} | |
struct CoroutineCancellation: ErrorType {} | |
class CoroutineImpl<InputType, YieldType> { | |
let body: (yield: YieldType throws -> InputType) throws -> Void |
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 WebClient { } | |
class WebClientImpl: WebClient { | |
} | |
class VMOne { | |
var client: WebClient | |
var prop: Int | |
init(client: WebClient, prop: Int) { |
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
#import <Foundation/Foundation.h> | |
int stringComp(const void *a, const void *b) { | |
NSString *aO = *(NSString *__autoreleasing*)a; | |
NSString *bO = *(NSString *__autoreleasing*)b; | |
return [aO caseInsensitiveCompare:bO]; | |
} | |
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, TemplateHaskell, EmptyDataDecls, TypeFamilies #-} | |
module Main where | |
import Debug.Trace (trace) | |
import Happstack.Server | |
import Web.Routes.Site | |
import Web.Routes.PathInfo (PathInfo (..), parseSegments) | |
import Web.Routes.Happstack |
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
Digestive functors | |
================== | |
CE: Misschien iets over HTML forms genereren? Dit is wellicht iets te abstract. Ook dat je controle hebt over error-correction en dat het composable is? Misschien uitleggen dat het een alternatief voor formlets is dat strikt beter is? | |
Digestive functors is a library that provides an abstract interface towards | |
input consumption. The interface is based on applicative functors. | |
> {-# LANGUAGE OverloadedStrings #-} | |
> import Text.Digestive |
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
extension Array { | |
func parallelMap<U>(transform: Element -> U) -> [U] { | |
var result: [U?] = Array<U?>(count: count, repeatedValue: nil) | |
dispatch_apply(count, dispatch_get_global_queue(0, 0)) { | |
result[$0] = transform(self[$0]) | |
} | |
return result.map { $0! } | |
} | |
} |
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
#import <UIKit/UIKit.h> | |
typedef UIImage*(^getTile)(CGFloat scale, int row, int col); | |
@interface TilingView : UIView { | |
getTile getTile; | |
} | |
- (id)initWithSize:(CGSize)size levelsOfDetail:(NSInteger)levelsOfDetail tileSize:(CGSize)tileSize; | |
@property (nonatomic,copy) getTile getTile; |
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
// This accompanies http://chris.eidhof.nl/posts/repmin-in-swift.html | |
import UIKit | |
// Unfortunately, we need Box | |
public class Box<T> { | |
public let unbox: T | |
public init(_ value: T) { self.unbox = value } | |
} |