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.Numerics; | |
using LanguageExt; | |
using LanguageExt.Common; | |
using LanguageExt.Traits; | |
using static LanguageExt.Prelude; | |
namespace ValidationExamples; | |
// Credit card number |
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
module Validation = | |
open LanguageExt | |
let successValue (ma : Validation<'f, 'a>) : 'a = | |
ma.IfFail(fun () -> failwith "Validation monad is in a Fail state") | |
let apply (mf : Validation<'f, 'a -> 'b>) (ma : Validation<'f, 'a>) : Validation<'f, 'b> = | |
mf.Disjunction(ma) | |
.Map(fun _ -> (successValue mf) (successValue ma)) | |
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
string? name = "Paul"; | |
string? noName = null; | |
// Only says hello if not null | |
var helloName = name.Map(n => $"Hello, {name}"); // "Hello, Paul" | |
var noHelloName = noName.Map(n => $"Hello, {name}"); // null | |
// Nullable strings ... | |
string? sx = "Hello"; | |
string? sy = "World"; |
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
#! /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
// | |
// See https://github.com/louthy/language-ext | |
// | |
using System; | |
using System.IO; | |
using System.Linq; | |
using System.Threading.Tasks; | |
using LanguageExt; | |
using static LanguageExt.Prelude; |
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; | |
namespace ConsoleApp1 | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var xs = new[] {"one", " ", "two", " ", "three"}; | |
var ys = new[] {1, 2, 3}; |
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 LanguageExt; | |
using static LanguageExt.Prelude; | |
namespace RiderCandidates | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ |
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
using System; | |
using System.Diagnostics.Contracts; | |
using System.Runtime.CompilerServices; | |
using System.Runtime.ExceptionServices; | |
using LanguageExt.Common; | |
using LanguageExt.DataTypes.Serialisation; | |
using static LanguageExt.Prelude; | |
namespace LanguageExt | |
{ |
NewerOlder