View Parser.cs
namespace CsParsec
{
using System;
using System.Collections.Generic;
using System.Text;
public class Unit
{
private Unit()
{
View on-tail-recursion.md

On the topic of tail calls in .NET

Let's say you have implemented a small data pipeline library to replace LINQ.

module TrivialStream =
  type Receiver<'T> = 'T            -> unit
  type Stream<'T>   = Receiver<'T>  -> unit

  module Details =
View MTransform2.scala
import java.util.concurrent.atomic.AtomicInteger
import scala.reflect._
import scala.util.control._
trait Default[+T] {
val zero: T
}
object Default {
View MTransform.scala
import scala.reflect._
sealed trait TransformResult[+T]
case class TransformContext(path: List[String]) {
def append(p: String) = TransformContext(p::path)
override def toString = path.reverse.mkString(".")
}
View Result.java
import java.util.function.Function;
public abstract class Result<T> {
public static <U> Result<U> good(U v) {
return new Good<U>(v);
}
public static <U> Result<U> bad(String message) {
return new Bad<U>(message);
View Prism.fs
module StackOverFlow =
type [<Struct>] Prism<'T, 'U> = Prism of ('T -> 'U option)*('T -> 'U -> 'T)
module Prism =
module Details =
let inline empty< ^T when ^T : (static member empty: ^T) > () =
(^T : (static member empty: ^T) ())
let inline apply1< ^T, ^U when ^T : (static member apply: ^U -> ^T) > t =
(^T : (static member apply: ^U -> ^T) t)
let inline unapply1< ^T, ^U when ^T : (static member unapply: ^T -> ^U) > u =
View Parser.fs
type [<Struct>] Maybe<'T> =
| Just of 'T
| Nothing
and 'T maybe = Maybe<'T>
module FsTokenParser =
type [<Struct>] Position =
{
Column : int
Row : int
View 0_FsTransducer2.fs
module FsTransducers =
type Context =
{
mutable Continue : bool
}
static member New () : Context = { Continue = true }
type Initializer = Context -> unit
type Folder<'S, 'T> = 'S -> 'T -> 'S
type Completer<'S> = Context -> 'S -> 'S
type [<Struct>] Reducer<'S, 'T> = R of (Initializer*Folder<'S, 'T>*Completer<'S>)
View permutations.fs
let rec distribute e = function
| [] -> [[e]]
| x::xs' as xs -> (e::xs)::[for xs in distribute e xs' -> x::xs]
let rec permute = function
| [] -> [[]]
| e::xs -> List.collect (distribute e) (permute xs)
let generatePermutations r (vs : _ []) =
let inline swap f t =
View pparse.clj
(defn psuccess [v p] (fn [t f] (t v p)))
(defn pfailure [p] (fn [t f] (f p)))
(def pfail (fn [s p] (pfailure p)))
(defn preturn [v] (fn [s p] (psuccess v p)))
(defn pbind [t uf] (fn [s p] ((t s p)
(fn [tv tp] ((uf tv) s tp))
(fn [tp] (pfailure tp)))))
(defn pmap [t m] (pbind