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
#include <ratio> | |
#include <type_traits> | |
namespace units { | |
template<class T, int V, class Scale> | |
struct unit | |
{ | |
static_assert(V != 0, "uint with exponent of 0 must be replaced by void"); |
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
let bindArgumentsAndGenerateScript (args : Dictionary<string, _>) t = | |
let generateCall c = c |> bindArgument args <!> (sprintf "CALL %s") | |
let appendLine (stringBuilder : string) s = stringBuilder + s + "\n" | |
let generateTryCatchBlock (i, c) s = | |
let successLabel = sprintf "_success_%d" i | |
let errorLabel = sprintf "_error_%d" i | |
controlled { | |
let! sb = c.Try |> generateCall <!> appendLine s | |
// ... |
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
{-# LANGUAGE LambdaCase #-} | |
{-# LANGUAGE OverloadedStrings #-} | |
module Main where | |
import Lib | |
import Control.Applicative | |
import Data.ByteString (ByteString) | |
import qualified Data.Attoparsec.ByteString as 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
using System; | |
namespace Immutable | |
{ | |
enum Qux { Qux1, Qux2 } | |
class Baz | |
{ | |
public Baz(Qux qux) | |
{ |
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.Runtime.CompilerServices; | |
namespace BadIdeas | |
{ | |
using static Props; // Boo, C#, why does this need to be located here? | |
interface IReadable<TName, out T> { } | |
interface IWritable<TName, in T> { } |
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
open System | |
type IMonoid<'t> = | |
abstract Zero : 't | |
abstract Combine : 't -> 't -> 't | |
let sumMonoid : IMonoid<int> = | |
{ new IMonoid<int> with | |
member __.Zero = 0 | |
member __.Combine x y = x + y } |
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.CodeDom.Compiler; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Threading; | |
using System.Threading.Tasks; | |
using Xunit; | |
using Xunit.Abstractions; | |
using Xunit.Sdk; |
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
struct successful_hresult | |
{ | |
HRESULT hr_; | |
HRESULT throw_if_failed(HRESULT hr) | |
{ | |
if (FAILED(hr)) | |
{ | |
throw ...; | |
} |
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; | |
using System.Collections.Generic; | |
using System.Reflection; | |
namespace ConsoleApplication | |
{ | |
class PropertyComparer : IEnumerable | |
{ | |
private readonly Dictionary<string, Func<object, object, bool>> _except = new Dictionary<string, Func<object, object, bool>>(); |
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
unsafe void Main() | |
{ | |
var s = "hello world"; | |
Console.WriteLine($"String hash code: {s.GetHashCode()}"); | |
var hashCode = RuntimeHelpers.GetHashCode(s); | |
Console.WriteLine($"Object hash code: {hashCode}"); | |
Console.WriteLine("Poking string..."); | |
fixed (char* cs = s) |