Skip to content

Instantly share code, notes, and snippets.

#I @"C:\Tools\System.Reactive"
#r "System.Core.dll"
#r "System.Reactive.dll"
type observable<'a> = System.Collections.Generic.IObservable<'a>
type observer<'a> = System.Collections.Generic.IObserver<'a>
module Observable =
open System
open System.Linq
@t0yv0
t0yv0 / gist:192353
Created September 23, 2009 22:39
another take on F# monads
module Monad =
type M<'T,'B when 'B :> Sig<'B>> =
interface end
and Sig<'B when 'B :> Sig<'B>> =
abstract member Return<'X> : 'X -> M<'X,'B>
abstract member Bind<'X,'Y> :
M<'X,'B> -> ('X -> M<'Y,'B>) -> M<'Y,'B>
> {-# LANGUAGE GADTs #-}
> module Example where
> import qualified Data.Map as M
Let's assume that requests are simple |String|s.
> type Request = String
When running a web continuation, either the computation is completely finished,
In this gist we will first show that we can beat the arc challenge
(http://www.paulgraham.com/arcchallenge.html), and then build the library that
shows how we did it. This gist is Literate Haskell and is of course executable. The packages needed are happstack-server and applicative-extras, installable using cabal.
Let's start with some imports (for now, you can ignore these)
> {-# LANGUAGE GADTs, TypeSynonymInstances #-}
> module ArcChallenge where
>
> import Control.Applicative
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 #-}
>
@viniciusteles
viniciusteles / gist:556029
Created August 29, 2010 06:20
Sete Atitudes para Hackear a Indústria de Software
Sete Atitudes para Hackear a Indústria de Software
By Klaus Wuestefeld
1) Torne-se excelente.
Seja realmente bom em alguma coisa. Não fique só choramingando ou
querendo progredir às custas dos outros. Não pense q pq vc sentou 4
anos numa faculdade ouvindo um professor falar sobre software q vc
sabe alguma coisa. Jogador de futebol não aprende a jogar bola tendo
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
@oxbowlakes
oxbowlakes / 3nightclubs.scala
Created May 13, 2011 15:14
A Tale of 3 Nightclubs
/**
* Part Zero : 10:15 Saturday Night
*
* (In which we will see how to let the type system help you handle failure)...
*
* First let's define a domain. (All the following requires scala 2.9.x and scalaz 6.0)
*/
import scalaz._
import Scalaz._
@t0yv0
t0yv0 / FSCGI.Structural.Converter.fs
Created June 30, 2011 01:07
An attempt to improve on OWIN<http://owin.org> in F#.
/// Converts structural encodings to proper FSCGI.* types.
module FSCGI.Structural.Converter
type private Encodings<'R,'W> =
('W -> Writer<'W>) *
('R -> Response<'R,'W>)
let private ConvertRequest (r : FSCGI.Request) : Request =
(
r.Headers,
@einblicker
einblicker / gist:1325753
Created October 30, 2011 10:05
type-level FizzBuzz
trait Nat {
type IsZero <: Bool
type Prev <: Nat
type Divisable[A <: Nat] = DivisableImpl[A, A]
type DivisableImpl[A <: Nat, B <: Nat] <: Bool
}
trait Z extends Nat {
type IsZero = True
type Prev = Nothing