some tools for diagrams in software documentation
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
// Data Nat = Z | S Nat | |
// | |
// plus : Nat -> Nat -> Nat | |
// plus Z y = y | |
// plus (S k) y = S (plus k y) | |
abstract class Nat { | |
} | |
class Zero : Nat { |
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
void Main() | |
{ | |
var d = new Dictionary<BigInteger, BigInteger>(); | |
var t = DateTime.Now; | |
var howfar = 0; | |
var r = 0; | |
for (int x = 0; x < 100000; x++) | |
{ | |
for (int i = 0; i < 10000000; i++) | |
{ |
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 Raven.Abstractions.Data; | |
using Raven.Abstractions.Logging; | |
using Raven.Bundles.Replication.Plugins; | |
using Raven.Json.Linq; | |
namespace RavenConflictResolverPlugin | |
{ | |
public class LastInWinsReplicationConflictResolver |
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.Linq; | |
using System.Reflection; | |
using System.Threading; | |
using Raven.Abstractions.Data; | |
using Raven.Client.Embedded; | |
using Raven.Client.Indexes; | |
namespace OctoQueues |
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 class ConcurrentGateway | |
{ | |
private ConcurrentQueue<Action> _workQueue = new ConcurrentQueue<Action>(); | |
private int _writeLock = 0; | |
[ThreadStatic] | |
private static AutoResetEvent _waitEvent = new AutoResetEvent(false); | |
protected static AutoResetEvent GetThreadWaitEvent() | |
{ |
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 PureIO { | |
/* | |
C# does not have proper sum types. They must be emulated. | |
This data type is one of 4 possible values: | |
- WriteOut, being a pair of a string and A | |
- WriteErr, being a pair of a string and A | |
- readLine, being a function from string to A |
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
/* | |
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) |
OlderNewer