Skip to content

Instantly share code, notes, and snippets.

View mattpodwysocki's full-sized avatar

Matthew Podwysocki mattpodwysocki

View GitHub Profile
#light
[<AutoOpen>]
module Operators =
let (||>) (x, y) f = f x y
module Map =
let transposeCombine m =
(m, m) ||> Map.fold_left (fun acc k1 m' ->
(acc, m') ||> Map.fold_left (fun acc' k2 v ->
private ImportDefinition[] GetImportDefinitions(Type implementationType)
{
var constructors = implementationType.GetConstructors()[0];
return from param in constructors.GetParameters()
select ReflectionModelServices.CreateImportDefinition(
new Lazy<ParameterInfo>(() => param),
AttributedModelServices.GetContractName(param.ParameterType),
AttributedModelServices.GetTypeIdentity(param.ParameterType),
Enumerable.Empty<string>(),
ImportCardinality.ExactlyOne,
let tl s =
match Seq.length s with
| 0 -> invalid_arg "s"
| 1 -> Seq.empty
| _ -> Seq.skip 1 s
let (|SeqCons|SeqNil|) = function
| s when Seq.is_empty s -> SeqNil
| s -> SeqCons(Seq.hd s, tl s)
#light
open System
open System.Collections.Generic
// Define the type class and it's global associations table
type IApproxEq<'a> =
abstract member approxEqual : 'a -> 'a -> bool
abstract member approxNotEqual : 'a -> 'a -> bool
public static class FuncExtensions
{
public static Func<TSource, TResult> ForwardCompose<TSource, TIntermediate, TResult>(
this Func<TSource, TIntermediate> func1, Func<TIntermediate, TResult> func2)
{
return source => func2(func1(source));
}
}
using System;
using System.Concurrency;
using System.Collections.Generic;
using Microsoft.Axum;
using System.Concurrency.Messaging;
public agent Program : channel Application
{
public Program()
{
{-# LANGUAGE MultiParamTypeClasses, ScopedTypeVariables, TypeSynonymInstances, FlexibleInstances #-}
module PingPong where
-- standard ping-pong actor example
import IO
import Monad
import Data.IORef
#light
// F# port of auction.scala: http://lampsvn.epfl.ch/svn-repos/scala/scala/trunk/docs/examples/actors/auction.scala
open System
open System.Threading
let (<--) (m:'msg MailboxProcessor) x = m.Post x
let unSome (Some x) = x
type AuctionMessage =
#light
let (<--) (m:_ MailboxProcessor) x = m.Post x
type TemperatureMessage =
| ToFahrenheit of double
| ToCelsius of double
| Stop
let temperatureAgent =
open System.IO
module Map =
let insertWith (f:'a -> 'a -> 'a) (k:'k) (a:'a) (m:Map<'k,'a>) : Map<'k,'a> =
match Map.tryFind k m with
| None -> Map.add k a m
| Some v -> Map.add k (f v a) m
let people = [("Seymour", "BOS");
("Franny", "DAL");