Skip to content

Instantly share code, notes, and snippets.

Ryan Riley panesofglass

Block or report user

Report or block panesofglass

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@panesofglass
panesofglass / Fiber.fs
Created Dec 8, 2019 — forked from Horusiath/Fiber.fs
Custom fibers implementation in F#
View Fiber.fs
open System
open System.Threading
type FiberResult<'a> = Result<'a, exn> option
[<Sealed;AllowNullLiteral>]
type Cancel(parent: Cancel) =
let mutable flag: int = 0
let mutable children: Cancel list = []
new() = Cancel(null)
@panesofglass
panesofglass / README.md
Created Jun 18, 2018 — forked from shawnbot/README.md
d3 voronoi interpolation!
View README.md
@panesofglass
panesofglass / FetchData.fs
Created Apr 9, 2018
FetchData component using Trail
View FetchData.fs
namespace BlazorApp1.Pages
open System
open System.Collections.Generic
open System.Linq
open System.Threading.Tasks
open System.Net.Http
open Microsoft.AspNetCore.Blazor
open Microsoft.AspNetCore.Blazor.Components
open Microsoft.AspNetCore.Blazor.Layouts
@panesofglass
panesofglass / fetch-tags.js
Created Apr 7, 2018
Fetch all tag urls on stackoverflow.com
View fetch-tags.js
fetch ('https://stackoverflow.com/').then(response => response.text()).then(html => {
let fragment = document.createRange().createContextualFragment(html);
let content = fragment.querySelectorAll('[rel=tag]');
for (let el of content) {
console.log(el.getAttribute('href'));
}
}).catch(error => console.error(error));
@panesofglass
panesofglass / free.fs
Created Apr 3, 2018 — forked from johnazariah/free.fs
Free Monad with Trampoline Infrastructure and Computation Builder
View free.fs
// F<'a> is any type with member 'map' of type ('a -> 'b) -> F<'a> -> F<'b>
type F<'a> = QIL<'a>
and S<'a> = F<Q<'a>>
and Q<'a> =
private
| Step of Step<'a>
| Bind of IBind<'a>
with
static member lift (k : F<'a>) : Q<'a> = Step (Suspend (fun () -> S<_>.map (Yield >> Step) k))
@panesofglass
panesofglass / README.md
Last active Mar 7, 2018
Use cases for .NET Interface Extensions
View README.md

Static Methods on Interfaces

Use Cases

  1. Define related sets or sequences of algorithms to be defined together (need explicit example)
  2. Specify required static extension methods for implementing things like LINQ or Rx.
  3. Transducers cannot currently be implemented efficiently in .NET. Transducers would need to use IEnumerable<_> as a base collection type rather than potentially more efficient implementations (or retaining the input's stype, e.g. List<_>, etc).
  4. F# modules such as List, Array, and Seq all provide functions that are the same in nature but differ by wrapper type.
@panesofglass
panesofglass / inference.fsx
Last active Aug 25, 2017
inference and builders
View inference.fsx
type Op =
| Add
| Multiply
static member TryParse input =
match input with
| "add" -> Some Add
| "multiply" -> Some Multiply
| _ -> None
type Command<'a> =
@panesofglass
panesofglass / apply.fsx
Last active Aug 21, 2017
F# async applicative using a custom operation
View apply.fsx
open System
type FSharp.Control.AsyncBuilder with
[<CustomOperation("and!", IsLikeZip=true)>]
member __.Merge(x, y, f) =
async {
let! token = Async.CancellationToken
let! x' = Async.StartChildAsTask x
let! y' = Async.StartChildAsTask y
do System.Threading.Tasks.Task.WaitAll([|x';y'|], cancellationToken = token)
@panesofglass
panesofglass / Test.fsx
Created Aug 10, 2017
TPL + single SqlConnection
View Test.fsx
#load "load-references-debug.fsx"
open System.Data.SqlClient
open FSharp.Data
[<Literal>]
let MasterCS = "Server=.;Database=master;Integrated Security=true;"
let createDB () =
use cmd = new SqlCommandProvider<"create database Test", MasterCS>(MasterCS)
cmd.Execute() |> ignore
@panesofglass
panesofglass / fizzbuzz.fsx
Last active Aug 8, 2017
Iron Yard FizzBuzz
View fizzbuzz.fsx
// type for fizzbuzz results
type FizzBuzzResult =
| FizzBuzz
| Fizz
| Buzz
| Number of int
let fizzbuzz n =
match n % 3, n % 5 with
| 0, 0 -> FizzBuzz
You can’t perform that action at this time.