Skip to content

Instantly share code, notes, and snippets.

@sgoguen
sgoguen / LoadServer.fsx
Created January 24, 2019 19:01
How to cancel an agent
// 1. Create a project and add Steego.FsPad as a Nuget dependency
// 2. Build your project and set this folder to your output
#I "bin/Debug/net461/"
#r "FSharp.Core.dll"
#r "Suave.dll"
#r "Steego.FsPad.dll"
module Watcher =
@sgoguen
sgoguen / treemap.fs
Created February 5, 2018 15:34
F# Tree Maps
module TreeMaps
type Map<'k,'v> =
| Map of ('v -> 'k -> 'v)
[<Struct>]
type ShallowMap<'k,'v,'c> =
| ShallowMap of value:'v * lookup:('k -> 'v -> 'c)
@sgoguen
sgoguen / PathReflection.fs
Created February 5, 2018 15:32
FSharp - Functions as Paths
open Microsoft.FSharp.Reflection
let rec listTypes(t:Type) =
[
if FSharpType.IsFunction(t) then
let(a,b) = FSharpType.GetFunctionElements(t)
yield a
if FSharpType.IsFunction(b) then
yield! listTypes(b)
else

Keybase proof

I hereby claim:

  • I am sgoguen on github.
  • I am sgoguen (https://keybase.io/sgoguen) on keybase.
  • I have a public key ASB7lHbtpeTVKV_POAjX-YXpSjuk3i7VMIMeAKJ0cFCrOgo

To claim this, I am signing this object:

@sgoguen
sgoguen / livehub.cs
Created October 25, 2017 22:53
Livehub
void Main() {
Util.CurrentQueryPath.Dump();
string url = "http://localhost:8080";
using (WebApp.Start(url, Configuration)) {
//Task.Run(DoTask);
Console.ReadLine();
}
@sgoguen
sgoguen / enumInvalidInstances.fs
Created October 17, 2017 17:52
Using FsCheck to Enumerate Invalid Instances
// In this example, we're using FsCheck in an unorthodox way.
// Typically you tell FsCheck to look for something that violates
// your rule. Here, we're reappropriating FsCheck's fuzz testing
// capabilities to enumerate everything that has been deemed
// "valid" to see if it's actually valid to help us figure out the rules.
type Money = decimal
type CouponType = FreeMail | FreeSide
type PaymentOption =
@sgoguen
sgoguen / index.html
Created September 29, 2017 21:55
Observable Webserver
<!DOCTYPE html>
<html>
<head>
<title>Object Watcher</title>
</head>
<body>
<div id="output"></div>
<!--Script references. -->
<!--Reference the jQuery library. -->
<script src="Scripts/jquery-2.0.3.min.js"></script>
@sgoguen
sgoguen / _about.md
Last active November 2, 2022 13:23
A Small Elm-like DSL in F#

Making Toys with F# - A Small Elm-like DSL in F#

A Small Elm-Like DSL in F#

I've been working on a talk about the virtues of building toy examples for the purpose of communicating ideas with simple interactive examples.

The toys I talk about in my presentation are based my interest in tools that allow programmers to quickly build web applications that allow them to explore their architecture. So to kickstart this series off, I want to introduce a simple

@import url( https://fonts.googleapis.com/css?family=Raleway:200,600 );
html, body { height: 100%; }
.wrapper {
position: absolute;
width: 727px !important;
left:-233px !important;
top: 0;
right: 0;
@sgoguen
sgoguen / _article.md
Last active June 23, 2017 01:24
Multiple File Test

A Better Way to Compose Web Applications

I don't care for the MVC pattern most of us use for building web applications. What I like about frameworks like ASP.MVC is how is automatically maps URLs to an idiomatic C# method.

public class PersonController : Controller {
  public ActionResult Get(int id) {
     return View(new { Id = id, Name = "Bob" });
 }