Skip to content

Instantly share code, notes, and snippets.


Reed Copsey, Jr. ReedCopsey

View GitHub Profile
ReedCopsey / Seq.fold
Last active Dec 20, 2019
F# Looping Sample Code
View Seq.fold
Seq.fold : ('State -> 'T -> 'State) -> 'State -> seq<'T> -> 'State
ReedCopsey / AvaloniaProgram.fs
Last active Dec 18, 2018
FsAdvent 2018 Code
View AvaloniaProgram.fs
let main _ =
let app () =
let nav = Gjallarhorn.Avalonia.Navigation.singleView app MainWindow
let app' = Program.application nav.Navigate
Gjallarhorn.Avalonia.Framework.RunApplication<Forest,unit,ForestMessage> (nav, app')
ReedCopsey / app.fs
Last active Dec 15, 2017
FsAdvent 2017 Code
View app.fs
let application nav =
// Start pruning "loop" via Executor type
let prune = new Executor<_,_>(pruneHandler)
// Start our application, and attach the executor so messages dispatch to the application
Framework.application Forest.empty Forest.update forestComponent nav
|> Framework.withDispatcher prune
ReedCopsey / test.cs
Created Aug 31, 2017
Linqpad C# Program
View test.cs
void Main()
IMsg test = new S2("foo", "bar");
switch (test)
// How do I simplify this??? I'd like to "match and deconstruct" as a oneliner if possible
case S1 s1:
int foo = s1.Data;
ReedCopsey / application.fs
Last active Dec 15, 2016
FsAdvent 2016 Code
View application.fs
let application =
// Create our forest, wrapped in a mutable with an atomic update function
let forest = new AsyncMutable<_>(Forest.empty)
// Create our 3 functions for the application framework
// Start with the function to create our model (as an ISignal<'a>)
let createModel () : ISignal<_> = forest :> _
// Create a function that updates our state given a message
View Manager.fs
type ForestUpdate =
| Add of Tree * Forest
| Decorate of Tree * Forest
type ForestUpdateResult =
| Success of Forest
| Pruned of Forest
| Error of string
module ForestManager =
View ActionCommand.cs
/// <summary>
/// An <see cref="ICommand"/> whose delegates do not take any parameters for <see cref="Execute"/> and <see cref="CanExecute"/>.
/// </summary>
public class ActionCommand : DelegateCommandBase
/// <summary>
/// Initializes a new instance of the <see cref="ActionCommand"/> class with the <see cref="Action"/> to invoke on execution.
/// </summary>
/// <param name="executeMethod">The execute method.</param>
/// <param name="useCommandManager">if set to <c>true</c> use the command manager instead of our own event process for CanExecuteChanged Tracking.</param>
View RwLock
using System;
using System.Threading;
public sealed class RwLock : IDisposable
private readonly ReaderWriterLockSlim _innerLock = new ReaderWriterLockSlim();
private bool _disposed = false;
public IDisposable Read()
ReedCopsey / Program.fs
Created Aug 23, 2014
Timing on Seq.toArray with ICollection<'T> input
View Program.fs
// Learn more about F# at
// See the 'F# Tutorial' project for more help.
open System.Diagnostics
let main argv =
let sequ = seq [ 1 .. 10000000 ]
let cach = ResizeArray<_>(sequ)
View Component.cs
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Cmc.Core.ComponentModel;
using Cmc.Core.Diagnostics;
using Cmc.Installer.Core.Tasks;
You can’t perform that action at this time.