This file contains 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
[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); |
This file contains 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
[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; |
This file contains 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
[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) |
This file contains 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 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); |
This file contains 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.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; |
This file contains 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
[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); |
This file contains 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
/// | |
/// 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; |
This file contains 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
> '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) | |
{ |
This file contains 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
#! /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 |
This file contains 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.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; |