Skip to content

Instantly share code, notes, and snippets.

View louthy's full-sized avatar
Focusing

Paul Louth louthy

Focusing
View GitHub Profile
public static class TupleExtensions
{
public static R Apply<T1, T2, R>(this Tuple<T1, T2> self, Func<T1, T2, R> func)
{
return func(self.Item1, self.Item2);
}
public static R Apply<T1, T2, T3, R>(this Tuple<T1, T2, T3> self, Func<T1, T2, T3, R> func)
{
return func(self.Item1, self.Item2, self.Item3);
namespace Language
{
public static class Helpers
{
public static Tuple<T1, T2> tuple<T1, T2>(T1 item1, T2 item2)
{
return Tuple.Create(item1, item2);
}
public static Tuple<T1, T2, T3> tuple<T1, T2, T3>(T1 item1, T2 item2, T3 item3)
@louthy
louthy / lang-ext-option-tests.cs
Last active June 29, 2016 18:24
language-ext Option vs FSharpOption construction
using LanguageExt;
using static LanguageExt.Prelude;
///////////////////////////////////////////////////////////////////////////////////
// Option<T> doesn't allow null use at all, and it's a struct, so any references
// also can't be null.
string noValue = null;
Option<string> str1 = noValue; // Implicitly coerced to None
Option<string> str2 = Optional(noValue); // Explicitly coerced to None
using System;
namespace TestTypeClasses
{
class Program
{
static void Main(string[] args)
{
var ma = Option.Some(2);
var mb = Option.Some(4);
@louthy
louthy / keybase.md
Created October 5, 2017 11:36
Keybase

Keybase proof

I hereby claim:

  • I am louthy on github.
  • I am louthy (https://keybase.io/louthy) on keybase.
  • I have a public key ASCeNsBy0zOFk4-hTP5CETDmMysT8kN4ZVD76Fu2hiO-iAo

To claim this, I am signing this object:

@louthy
louthy / Dispatch.fs
Created January 18, 2018 14:30
Echo - Dispatch fs
namespace Echo
open System
open ProcessFs
module DispatchFs =
/// Registers a dispatcher for a role
/// Dispatchers take in a 'leaf' ProcessId (i.e. /user/my-process) and return an enumerable
/// of real ProcessIds that the Process system will use to deliver all of the standard functions
@louthy
louthy / Role.fs
Created January 18, 2018 14:31
Echo - Role fs
namespace Echo
open System
open ProcessFs
module RoleFs =
let Broadcast = Echo.Role.Broadcast
let LeastBusy = Echo.Role.LeastBusy
let RoundRobin = Echo.Role.RoundRobin
@louthy
louthy / Router.fs
Created January 18, 2018 14:33
Echo - Router fs
namespace Echo
open LanguageExt
open LanguageExt.UnitsOfMeasure
open System
open ProcessFs
module RouterFs =
let DefaultRouterOption = Echo.RouterOption.Default
@louthy
louthy / Prelude.fs
Last active January 18, 2018 14:37
Echo - Prelude fs
namespace Echo
open LanguageExt
open LanguageExt.UnitsOfMeasure
open System
open Microsoft.FSharp.Data.UnitSystems.SI.UnitNames
module ProcessFs =
type SessionId = Echo.SessionId
using System;
using System.Linq;
using LanguageExt;
using LanguageExt.Parsec;
using static LanguageExt.Prelude;
using static LanguageExt.Parsec.Char;
using static LanguageExt.Parsec.Expr;
using static LanguageExt.Parsec.Token;
using static LanguageExt.Parsec.Prim;
using System.Reactive.Subjects;