Skip to content

Instantly share code, notes, and snippets.

@t0yv0
t0yv0 / SynchronousMessagePassing.fs
Created December 15, 2011 22:31
Demonstrates specializing F# Async for better CML-style channel performance.
(*
Copyright (c) 2008-2011 IntelliFactory
GNU Affero General Public License Usage The code
is free software: you can redistribute it and/or
modify it under the terms of the GNU Affero
General Public License, version 3, as published by
the Free Software Foundation.
anonymous
anonymous / gist:1406238
Created November 29, 2011 20:09
Originally:
https://gist.github.com/7565976a89d5da1511ce
Hi Donald (and Martin),
Thanks for pinging me; it's nice to know Typesafe is keeping tabs on this, and I
appreciate the tone. This is a Yegge-long response, but given that you and
Martin are the two people best-situated to do anything about this, I'd rather
err on the side of giving you too much to think about. I realize I'm being very
critical of something in which you've invested a great deal (both financially
anonymous
anonymous / RegexExtensions.fs
Created November 22, 2011 16:49
F# regex active patterns proposal #2 for fsharpx
namespace Extensions
open System.Text.RegularExpressions
///Regex extensions
module Regex =
type ActiveMatch =
{
Match: Match
MatchValue: string
Groups: Group list
@loudej
loudej / HomeController.cs
Created November 14, 2011 18:37
asp.net does not actually support multiple same-named incoming headers
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Web.Mvc;
namespace HeaderChecking.Controllers
{
public class HomeController : Controller
{
public ActionResult Index()
@t0yv0
t0yv0 / AsyncSockets.fs
Last active September 7, 2023 11:45
Asynchronous socket programming with F# async.
open System.Net.Sockets
type A = System.Net.Sockets.SocketAsyncEventArgs
type B = System.ArraySegment<byte>
exception SocketIssue of SocketError with
override this.ToString() =
string this.Data0
/// Wraps the Socket.xxxAsync logic into F# async logic.
@hodzanassredin
hodzanassredin / FileSystemTypeProvider.fs
Created September 25, 2011 19:57
Sample of file system TypeProvider
namespace FilesTypeProvider
open System.Reflection
open Microsoft.FSharp.Core.CompilerServices
open Samples.FSharpPreviewRelease2011.ProvidedTypes
open System.Text.RegularExpressions
[<TypeProvider>]
type public CheckedFilesProvider() as this =
@naveensrinivasan
naveensrinivasan / Readromannumerals
Created September 22, 2011 18:57
Read roman numerals in F#
(*
http://4clojure.com/problem/92
Roman numerals are easy to recognize, but not everyone knows all the rules necessary to work with them.
Write a function to parse a Roman-numeral string and return the number it represents.
You can assume that the input will be well-formed, in upper-case, and follow the subtractive principle.
You don't need to handle any numbers greater than MMMCMXCIX (3999), the largest number representable with ordinary letters.
(= 14 (__ "XIV"))
PS1_BASE="$PS1"
format_prompt () {
if [ "$?" -ne "0" ]; then
PS1="${PS1_BASE}\[\033[0;31m\]ಠ_ಠ\[\033[0m\] "
else
PS1="${PS1_BASE}"
fi
}
PROMPT_COMMAND=format_prompt
@t0yv0
t0yv0 / MapReduce.fs
Created August 7, 2011 03:40
F# map-reduce with fully asynchronous arbitrary-order mappers and reducers.
let mapReduce (map : 'T1 -> Async<'T2>)
(reduce : 'T2 -> 'T2 -> Async<'T2>)
(input : seq<'T1>) : Async<'T2> =
let run (a: Async<'T>) (k: 'T -> unit) =
Async.StartWithContinuations(a, k, ignore, ignore)
Async.FromContinuations <| fun (ok, _, _) ->
let k = ref 0
let agent =
new MailboxProcessor<_>(fun chan ->
async {
@jasonsirota
jasonsirota / wcfowin.cs
Created August 4, 2011 17:51
WCF OWIN
using System;
using System.Collections.Generic;
using System.Configuration;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading;
using System.Threading.Tasks;