Skip to content

Instantly share code, notes, and snippets.

public class DiagnosticsSubstitutionContext : ISubstitutionContext
{
[ThreadStatic]
private static IList<IArgumentSpecification> LastDequeuedList;
private static ConcurrentDictionary<IArgumentSpecification, ArgumentInfo> ArgumentInfos { get; } = new ConcurrentDictionary<IArgumentSpecification, ArgumentInfo>();
private class ArgumentInfo
{
public string CreationStack { get; }
public int DequeueCounter { get; set; }
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeFamilies #-}
import Control.Lens
import Data.Maybe
import Data.Monoid
import Data.Tagged
--
-- Copyright © 2013-2014 Anchor Systems, Pty Ltd and Others
--
-- The code in this file, and the program it is a part of, is
-- made available to you by its authors as open source software:
-- you can redistribute it and/or modify it under the terms of
-- the 3-clause BSD licence.
--
module Main where
#I @"g:\prg\Fleece\Fleece\bin\Release\"
#r @"FsControl.Core.dll"
#r @"FSharpPlus.dll"
#r @"System.Json.dll"
#r @"ReadOnlyCollectionsInterfaces.dll"
#r @"ReadOnlyCollectionsExtensions.dll"
#r @"Fleece.dll"
open System
open System.Collections.Generic
@bitemyapp
bitemyapp / gist:e03b415925b8d5e61bf5
Created June 2, 2014 05:19
Edward's Category Theory recommendations

There is no "one size fits all" answer to this question.

It strongly depends on the context of the reader.

That said, I can offer several suggestions for different demographics.

If you are starting from zero and have little background with mathematics as a whole then Conceptual Mathematics: A First Introduction to Categories by Lawvere and Schanuel is probably the best starting point. It doesn't go deep or far, but it does supply you with a lot of drill for the material it does cover, which is quite rare for a category theory textbook!

If you have a lot of "mathematical maturity" probably the most dense book on the topic is Categories for the Working Mathematician by Saunders Mac Lane. I personally bounced off this book a half-dozen times trying to work through it, but in the end was able to make it through. The journey is tough, but the reward at the end is worth it. It is a very comprehensive summary of 1-category theory, and nicely ties up the core ideas at that level. The last chapter is enough of an

@shiftkey
shiftkey / explore.md
Last active July 27, 2022 13:24
WTF happened to my line endings?

This is a quick guide to debug potential line ending weirdness.

Note: I've thrown a lot of concepts in here around Git data structures without going into depth. If there's things that are unclear or you'd like some more details, just leave a comment and I'll either reply or expand on this post accordingly...

What sort of weirdness am I referring to? Consider this commit: https://github.com/dalefrancis88/Windsor/commit/e2543e5573781c7ded83166932c9c415feef11c0

While it looks like a very large commit, the contents of the file are unchanged. But the diffs are very intimidating.

@bitemyapp
bitemyapp / gist:ac316a6eb666695ff7d2
Last active November 4, 2020 04:11
How I talk about Haskell when I want people to care about learning Haskell

Fire up ghci. Make the text real big. Always show the types for everything as you go!

Takes ~1 hour generally.

Note: if you object to "uncertainty" (evocative of data/value flow possibilities), consider wording like "simultaneously possible values". It's a reference to how the compiler won't know whether Maybe a is a Just a or a Nothing statically. Don't blather at me about dependent types; I know.

Alternate verbiage for uncertainty: product - simultaneous altogetherness, sum - simultaneous singlehood. Also consider what the category theoretic diagrams look like. Can be instructive.

Suggestions taken under advisement.

#!/bin/sh
# Attempts to build a cabal binary package and symlink it in ~/.cabal/bin/
# Don't do this for binaries that rely on other assets! (such as pandoc)
# USE AT YOUR OWN RISK!
set -e
ws="[^a-zA-Z0-9\-\.]"
if [ "$#" -ne 1 ]
then
@ColinScott
ColinScott / gist:9443227
Created March 9, 2014 05:22
Adding ExpectedObjects to NSubstitute
This adds a new Arg.ShouldMatch<T> method that uses expected objects to verify the received argument matches the expected object. For example the code below gives an error message of "ReceivedCallsException: Expected to receive exactly 1 call matching:
Blah(For Thing.Stuff, expected "Whatever2" but found "Whatever".
For Thing.OtherStuff, expected "abcd2" but found "abcd".
)
Actually received no matching calls.
Received 1 non-matching call (non-matching arguments indicated with '*' characters):
Blah(*Thing*)"
void Main()
{
@tonymorris
tonymorris / PureIO.cs
Last active April 2, 2022 16:23
A demonstration of pure-functional I/O using the free monad in C#
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