Skip to content

Instantly share code, notes, and snippets.

View louthy's full-sized avatar
Focusing

Paul Louth louthy

Focusing
View GitHub Profile
[System.Serializable]
public sealed class Just<A> : Maybe<A>, System.IEquatable<Just<A>>, System.IComparable<Just<A>>, System.IComparable
{
public readonly A Value;
public Just(A Value)
{
this.Value = Value;
}
public static Just<A> New(A Value) => new Just<A>(Value);
[System.Serializable]
public sealed class Rectangle<NumA, A> : _ShapeBase<NumA, A>, System.IEquatable<Rectangle<NumA, A>>, System.IComparable<Rectangle<NumA, A>>, System.IComparable where NumA : struct, Num<A>
{
public readonly A Width;
public readonly A Length;
public override int @Tag => 1;
public Rectangle(A Width, A Length)
{
this.Width = Width;
this.Length = Length;
[System.Serializable]
public sealed class Just<A> : Maybe<A>, System.IEquatable<Just<A>>, System.IComparable<Just<A>>, System.IComparable
{
public readonly A Value;
public Just(A Value)
{
this.Value = Value;
}
public void Deconstruct(out A Value)
public partial struct Subsystem<A>
{
readonly LanguageExt.Reader<TestBed.IO, A> computation;
internal Subsystem(LanguageExt.Reader<TestBed.IO, A> comp) => computation = comp;
public static Subsystem<A> Pure(A value) => new Subsystem<A>(Prelude.Reader<TestBed.IO, A>(value));
public static Subsystem<A> Fail(string message) => new Subsystem<A>(Prelude.ReaderFail<TestBed.IO, A>(message));
public static Subsystem<A> Fail(System.Exception exception) => new Subsystem<A>(Prelude.ReaderFail<TestBed.IO, A>(exception));
public static Subsystem<A> Fail(string message, System.Exception exception) => new Subsystem<A>(Prelude.ReaderFail<TestBed.IO, A>(message, exception));
public Subsystem<B> Map<B>(System.Func<A, B> f) => Bind(a => Subsystem<B>.Pure(f(a)));
public Subsystem<B> Select<B>(System.Func<A, B> f) => Map(f);
@louthy
louthy / issue716.cs
Last active February 12, 2020 23:25
using System;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Ink;
using System.Windows.Input;
using LanguageExt;
using LanguageExt.ClassInstances;
using static LanguageExt.Prelude;
using static System.IO.File;
using static WpfApp1.Parsers;
[System.Serializable]
public partial struct Person : System.IEquatable<Person>, System.IComparable<Person>, System.IComparable
{
public Person(string Forename, string Surname)
{
this.Forename = Forename;
this.Surname = Surname;
}
public static Person New(string Forename, string Surname) => new Person(Forename, Surname);
///
/// Example of a validation applicative and writer monad merged into a single type
///
using System;
using LanguageExt;
using static LanguageExt.Prelude;
using LanguageExt.ClassInstances;
using LanguageExt.TypeClasses;
using LanguageExt.Common;
@louthy
louthy / foreach.txt
Created June 20, 2019 15:19
Foreach
> 'Typical foreach looks are no different'
well, they are, they are full of unecessary boilerplate for many operations. If you have a first-class function for the ForEach handler then:
```
things.ForEach(YourFunc)
```
Is easier than:
```
foreach(var thing in things)
{
@louthy
louthy / recon.ml
Created November 6, 2018 02:02 — forked from kseo/recon.ml
A Hindley-Milner type inference implementation in OCaml
#! /usr/bin/env ocamlscript
Ocaml.ocamlflags := ["-thread"];
Ocaml.packs := [ "core" ]
--
open Core.Std
type term =
| Ident of string
| Lambda of string * term
| Apply of term * term
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;