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.Threading; | |
using static System.Console; | |
public class Test | |
{ | |
public static void Main() | |
{ | |
var p = new StackPool<S>(); | |
var s1 = Rent(p, "55"); |
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
<!-- Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. --> | |
<Project> | |
<PropertyGroup> | |
<!-- Respect environment variable for the NuGet Packages Root if set; otherwise, use the current default location --> | |
<NuGetPackageRoot Condition="'$(NuGetPackageRoot)' == ''">$(NUGET_PACKAGES)</NuGetPackageRoot> | |
<NuGetPackageRoot Condition="'$(NuGetPackageRoot)' == '' AND '$(OS)' == 'Windows_NT'">$(UserProfile)\.nuget\packages\</NuGetPackageRoot> | |
<NuGetPackageRoot Condition="'$(NuGetPackageRoot)' == '' AND '$(OS)' != 'Windows_NT'">$([System.Environment]::GetFolderPath(SpecialFolder.Personal))\.nuget\packages\</NuGetPackageRoot> | |
<NuGetPackageRoot Condition="!HasTrailingSlash('$(NuGetPackageRoot)')">$(NuGetPackageRoot)\</NuGetPackageRoot> | |
</PropertyGroup> | |
</Project> |
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; | |
public class C { | |
public Result<int>.Or M() => | |
Result<int>.Left(2); | |
} | |
public class Result<T> : Either<T, Exception> {} | |
public class Either<L, R> | |
{ |
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
/* | |
Modified from the original https://gist.github.com/louthy/524fbe8965d3a2aae1b576cdd8e971e4 | |
- removed dependency on [language-ext](https://github.com/louthy/language-ext) | |
- separated monadic boilerplate, so you may concentrate on describing the operations and interpretation of the program | |
- removed `IO<A>.Faulted` to simplify the examples. It can be added back in straightforward manner. | |
Useful links: | |
- [John DeGoes: Beyond Free Monads - λC Winter Retreat 2017](https://www.youtube.com/watch?v=A-lmrvsUi2Y) | |
- [Free and tagless compared - how not to commit to a monad too early](https://softwaremill.com/free-tagless-compared-how-not-to-commit-to-monad-too-early) |
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; | |
namespace FP | |
{ | |
// final case class Cofree[F[_], A](head: A, tail: F[Cofree[F, A]]) | |
public interface ICofree<F, _, A> | |
{ | |
A Head { get; } | |
CofreeF Tail<CofreeF>() where CofreeF : ICofree<F, _, A>; | |
} |
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
// Modified from the original https://gist.github.com/louthy/524fbe8965d3a2aae1b576cdd8e971e4 | |
using System; | |
using System.IO; | |
using System.Linq; | |
using System.Collections.Generic; | |
using System.Threading.Tasks; | |
using static System.Linq.Enumerable; | |
using static IOExample.Unit; |
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
#define USE_EXPRESSION_INFO // I am here! | |
namespace NServiceBus | |
{ | |
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Linq.Expressions; | |
using System.Reflection; | |
using System.Threading.Tasks; |
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 BenchmarkDotNet.Attributes; | |
namespace Playground | |
{ | |
[MemoryDiagnoser] | |
public class DelegateVsInterfaceStruct | |
{ | |
[Params(10, 100, 1000)] public int ArraySize; |
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
Func<Func<T,T,T>, Func<T,T,T>> Mapping<T>(Func<T,T> map) | |
{ | |
return reduce => (sum, item) => reduce(sum, map(item)); | |
} | |
Func<Func<T,T,T>, Func<T,T,T>> Filtering<T>(Func<T,bool> condition) | |
{ | |
return reduce => (sum, item) => condition(item) ? reduce(sum, item) : sum; | |
} |
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
import Html exposing (div, button, text, input, p) | |
import Html.App exposing (beginnerProgram) | |
import Html.Events exposing (onClick, onInput) | |
import Html.Attributes exposing (placeholder, value) | |
main = | |
beginnerProgram { model = model, view = view, update = update } | |