This file contains hidden or 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
#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 -> |
This file contains hidden or 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
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, |
This file contains hidden or 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
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) |
This file contains hidden or 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
#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 |
This file contains hidden or 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
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)); | |
} | |
} | |
This file contains hidden or 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
using System; | |
using System.Concurrency; | |
using System.Collections.Generic; | |
using Microsoft.Axum; | |
using System.Concurrency.Messaging; | |
public agent Program : channel Application | |
{ | |
public Program() | |
{ |
This file contains hidden or 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 MultiParamTypeClasses, ScopedTypeVariables, TypeSynonymInstances, FlexibleInstances #-} | |
module PingPong where | |
-- standard ping-pong actor example | |
import IO | |
import Monad | |
import Data.IORef |
This file contains hidden or 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
#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 = |
This file contains hidden or 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
#light | |
let (<--) (m:_ MailboxProcessor) x = m.Post x | |
type TemperatureMessage = | |
| ToFahrenheit of double | |
| ToCelsius of double | |
| Stop | |
let temperatureAgent = |
This file contains hidden or 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
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"); |